I am trying to print a message by using the code below:
org 100h
start:
jmp begin
begin:
mov ah, 9
mov dx, msg
msg db 'Ascii sign:.$'
int 21h
finish:
mov ax, 4c00h
int 21h
It is able to compile but it display nothing at all. But if I move the line "msg db 'Ascii sign:.$'" below "jmp begin", the message is able to display.
I want to know the logic behind this. Does that make a difference where I declare the message ?
This is just out of curiosity, thank you!
Yes. Right now, msg
is defined in the middle of the code, where the CPU will attempt to execute it. You normally want to define data separately, in the data segment. I don't remember the syntax for FASM, but with MASM or TASM, you'd normally do something like this:
.model small
.data
msg db 'ASCII sign: .$'
.code
main proc
mov ah, 9
mov dx, offset msg
int 21h
mov ax, 4c00h
int 21h
main endp
end main