The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: Xor Stance on January 16, 2005, 05:39:23 AM

Title: procedure help!
Post by: Xor Stance on January 16, 2005, 05:39:23 AM
.model tiny
.code
org 100h
start:
call Display_Hi
mov ah,4c00h
int 21h

Display_Hi PROC
mov dx,OFFSET HI
mov ah,9
int 21h
ret
Display_Hi ENDP

HI DB "Hello World$"

end start


I definitely can't compile it.
Title: Re: procedure help!
Post by: thomasantony on January 16, 2005, 07:35:34 AM
Hi,
  Try doing this

.model tiny
.stack
assume cs:_TEXT, ds:_TEXT, ss:_TEXT
_TEXT SEGMENT
org 100h
start:
call Display_Hi
mov ah,4c00h
int 21h

Display_Hi PROC
mov dx,OFFSET HI
mov ah,9
int 21h
ret
Display_Hi ENDP
_TEXT ends
end start

I haven't tested it but that should work

Thomas Antony
Title: Re: procedure help!
Post by: MichaelW on January 16, 2005, 06:57:33 PM
Assuming you are usings MASM, it should be returning an error message that identifies the problem:

Assembling: test.asm
test.asm(6) : error A2070: invalid instruction operands

The instruction on line 6 is:

mov ah,4c00h

Which is trying to move a 16-bit constant into an 8-bit register.
Title: Re: procedure help!
Post by: Xor Stance on January 17, 2005, 03:53:08 AM
Thanks, I didn't noted about that mistake I did and thanks Thomas too; I will learn it by both ways.
Title: Re: procedure help!
Post by: Xor Stance on January 18, 2005, 01:07:02 AM
Hi Thomas,

Your code displays me an error.
.asm(8) : error A2070: invalid instruction operands
.asm(12) : error A2006: undefined symbol : HI


My sample code

actually I use ax instead of ah, and it worked.
Title: Re: procedure help!
Post by: thomasantony on January 18, 2005, 07:56:26 AM
Sorry,
    Yeas you should use ax and you should also define the string HI right after Display_Hi ENDP like this

Display_Hi ENDP
HI DB "Hello World$"


Thomas Antony :U
Title: Re: procedure help!
Post by: Vortex on January 18, 2005, 10:44:44 AM
Xor Stance,

Your application is a COM file, you can terminate it also with int 20h
Title: Re: procedure help!
Post by: Xor Stance on January 19, 2005, 12:46:18 AM
Thanks,
.model tiny
.stack
assume cs:_TEXT, ds:_TEXT, ss:_TEXT
_TEXT SEGMENT
org 100h
start:
call Display_Hi
mov ah,4c00h
int 21h

Display_Hi PROC
mov dx,OFFSET HI
mov ah,9
int 21h
ret
Display_Hi ENDP
HI DB "Hello World$"
_TEXT SEGMENT ends

end start


Still displays me an error.

.asm(8) : error A2070: invalid instruction operands
.asm(18) : error A2008: syntax error : ends
Title: Re: procedure help!
Post by: thomasantony on January 19, 2005, 06:59:17 AM
Hi,
    Okay, Here is the code from my first 16-bit MASM prog :P . Change it according to what you want!!

.model tiny
.stack
assume cs:_TEXT, ds:_TEXT, ss:_TEXT
_TEXT SEGMENT
org 0h
entry:
mov ax,cs
mov dx,ax
mov dx,OFFSET Hello
mov ah,09h
int 21h

mov ax,4C00h
int 21h
ret

Hello db "Hello World",13,10,"$"
_TEXT ends
end entry

Compile using the ml.exe from MASM32 package using ml /c yourfilename.asm
Link it using the 16-bit linker.

Thomas Antony :U
Title: Re: procedure help!
Post by: Xor Stance on January 19, 2005, 04:26:11 PM
Thanks Thomas, that works.