help with assembly programming 
Author Message
 help with assembly programming

Here is some code that would make a COM file (you need to set the starting
address to be 100h)

.model tiny
.code
  org 100h
start:
  mov dx, offset Message
  mov ah, 9
  int 21h

  mov ax, 4c00h
  int 21h

.data
  Message db "Hello World$"
end start

And you should compile your file as follows (i'm assuming you're using TASM)

tasm test.asm
tlink /t test.obj

Good Luck!

..-=ViKtOr=-..

Quote:

> Hey all,

> Could someone tell me what I'm doing wrong? - I want to make a .com assembly
> program to print a hello world message.  I'm able to do it as a .exe, but I
> can't get the .com version to work properly.  Following is my exe code
> ----
> .model small
> .stack 100h
> .radix 16
> .data
> message db "hello world!",'$'
> .code
> start:
> mov ax,seg message
> mov ds,ax
> mov dx,offset message

> mov ah,9
> int 21

> mov ah,4c
> mov al,0
> int 21
> end start
> ----

> It was my understanding that I could remove the following lines (and change
> model to tiny) and compile the .com equivalent

> ----
> .model tiny ;  small
> ;  .stack 100h
> .radix 16
> .data
> message db "hello world!",'$'
> .code
> start:
> ;  mov ax,seg message
> ;  mov ds,ax
> mov dx,offset message

> mov ah,9
> int 21

> mov ah,4c
> mov al,0
> int 21
> end start
> ----

> I'd appreciate any help.. thanks in advance.

> Keith



Thu, 14 Feb 2002 03:00:00 GMT  
 help with assembly programming
You have to use exe2bin.exe to make a .com program.
Bye


Quote:
> Hey all,

> Could someone tell me what I'm doing wrong? - I want to make a .com
assembly
> program to print a hello world message.  I'm able to do it as a .exe, but
I
> can't get the .com version to work properly.  Following is my exe code
> ----
> .model small
> .stack 100h
> .radix 16
> .data
> message db "hello world!",'$'
> .code
> start:
> mov ax,seg message
> mov ds,ax
> mov dx,offset message

> mov ah,9
> int 21

> mov ah,4c
> mov al,0
> int 21
> end start
> ----

> It was my understanding that I could remove the following lines (and
change
> model to tiny) and compile the .com equivalent

> ----
> .model tiny ;  small
> ;  .stack 100h
> .radix 16
> .data
> message db "hello world!",'$'
> .code
> start:
> ;  mov ax,seg message
> ;  mov ds,ax
> mov dx,offset message

> mov ah,9
> int 21

> mov ah,4c
> mov al,0
> int 21
> end start
> ----

> I'd appreciate any help.. thanks in advance.

> Keith



Sat, 16 Feb 2002 03:00:00 GMT  
 help with assembly programming
Hey all,

Could someone tell me what I'm doing wrong? - I want to make a .com assembly
program to print a hello world message.  I'm able to do it as a .exe, but I
can't get the .com version to work properly.  Following is my exe code
----
.model small
.stack 100h
.radix 16
.data
message db "hello world!",'$'
.code
start:
mov ax,seg message
mov ds,ax
mov dx,offset message

mov ah,9
int 21

mov ah,4c
mov al,0
int 21
end start
----

It was my understanding that I could remove the following lines (and change
model to tiny) and compile the .com equivalent

----
.model tiny ;  small
;  .stack 100h
.radix 16
.data
message db "hello world!",'$'
.code
start:
;  mov ax,seg message
;  mov ds,ax
mov dx,offset message

mov ah,9
int 21

mov ah,4c
mov al,0
int 21
end start
----

I'd appreciate any help.. thanks in advance.

Keith



Sun, 17 Feb 2002 03:00:00 GMT  
 help with assembly programming
     I don't know what assembler you are using, so this is just a shot in
the dark, but try the fixed code below.   I use A86 usually, so I'll run
this and see what happens since A86 works fine with MASM/TASM based code.

.model tiny
 .radix 16
.code
 org 100h
 jmp start
 message db 'hello world!','$'
start:
 mov dx,offset message
 mov ah,9
 int 21
ret
end start

     Well, it makes a .COM through A86.   Good luck!!!

SK



Sun, 17 Feb 2002 03:00:00 GMT  
 help with assembly programming

First of all don't declare stack if you want to make COM file and second,
put 'org 100h' after you declare .code segment. this is very important.
Your code could look like the one below.  Compile it with TASM or A86.  
If you use TASM use TLINK /t  to produce COM output.

.model small
.code
org 100h

start:

mov dx,offset message   ; DS is equal to CS
mov ah,9                        
int 21h

mov ax,4C00h
int 21h

message db "hello world!",'$'

end start



Sun, 17 Feb 2002 03:00:00 GMT  
 help with assembly programming
     Just to let you know, the stack seg was commented out of the author's
code, so I think he/she understands that aspect.

Quote:
> First of all don't declare stack if you want to make COM file...

SK


Sun, 17 Feb 2002 03:00:00 GMT  
 help with assembly programming
Thank you both (Seth, Artur) for your input - org 100h did the trick.
Appreciate your help!

Peace,
Keith


Quote:
>      Just to let you know, the stack seg was commented out of the author's
> code, so I think he/she understands that aspect.

> > First of all don't declare stack if you want to make COM file...

> SK



Sun, 17 Feb 2002 03:00:00 GMT  
 help with assembly programming

Quote:

> You have to use exe2bin.exe to make a .com program.

     No you don't.   Run this through A86 and you will have a .COM program
with no further efforts:

code    segment
        org     100h
        jmp     start
buff    db      '---'
msg1    db      0Dh,0Ah,'Type in a y for Yes or an n for No, followed by
ENTER.'
        db      0Dh,0Ah,'-> $'
msgn db 0Dh,0Ah,'You elected to type:   n   Following the sub-routine
labeled:  no','$'
msgy db 0Dh,0Ah,'You elected to type:   y   Following the sub-routine
labeled:  yes','$'
msgx db 0Dh,0Ah,'You did not enter a valid command.  Remember, lower-case
only.','$'
crlf    db      0Dh,0Ah,0Ah,'$'
start:
        push    bp
        mov     ax,0600h
        mov     bx,0700h
        mov     cx,0
        mov     dx,2A50h
        int     10h
        pop     bp
        mov     ah,02
        mov     dx,0
        mov     bx,0
        int     10h
Take:
        mov     ah,9
        mov     dx,offset msg1
        int     21h
        mov     dx,offset buff
        mov     si,offset buff
        mov     byte ptr [si],2
        mov     ah,0Ah
        int     21h
        mov     si,offset buff + 2
        mov     al,[si]
        cmp     al,110
        je      no
 cmp al,121
 je yes
 jne badresp
no:
 mov ah,9
 mov dx,offset msgn
 int 21h
 jmp quit
yes:
 mov ah,9
 mov dx,offset msgy
 int 21h
 jmp quit
badresp:
 mov ah,9
 mov dx,offset msgx
 int 21h
 jmp Take
quit:
        mov     ah,9
        mov     dx,offset crlf
        int     21h
        int     20h
end

   I'm glad I pulled this out to paste here, I see some things I can do to
speed it up and clean up the code:
     I should put the 'badresp' routine right under the 'je yes', and get
rid of a jcc instruction.   I'm getting a single letter from the user
through keyboard input, and I could make that MUCH quicker with an
int21h,01h since I don't need to buffer the input.   Well, it's one of the
first two programs I ever wrote, although I used a routine I learned from
someone here for the keyboard input part so I guess its not *all* mine.
Anyway, it assembles into a .COM as is.

Regards,
Seth

P.S.   For what its worth, the above code is freeware (probably only useful
for newbies to tear apart).   Write me privately for a copy with comments,



Mon, 18 Feb 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. help-recursive assembly program

2. help for Assembly program

3. Need help with Assembly Program...

4. Need help with Assembly Program...

5. C++ and Assembly Programming need help in Linux pleaseeeeeeeeeeeeeeeeeeee

6. Assembly Program help, please!!

7. Help on MC68332 Assembly Language Program!!!

8. programming help wanted: assembly FFT code

9. C++ and Assembly Programming need help in Linux pleaseeeeeeeeeeeeeeeeeeee

10. help on 32bit assembly programming

11. Gracious help needed with Assembly programming !

12. ** HELP !!! Floppy controller FDC direct assembly programming **

 

 
Powered by phpBB® Forum Software