8086 Program :: Display String

.model small

.stack

.data
message db "My First Assembly Language Program$"

.code

main proc
    mov ax, seg Message 
                ;moves the SEGMENT that 'Message' is in into AX
                ;equivalent to MOV ax,@data
    mov ds,ax  
                ;moves ax into ds (ds=ax)
                ;you can not do this ->mov ds, seg Message
    mov dx,offset Message 
                ;moves the OFFSET of 'Message' into DX
                ;equivalent to LEA dx,Message
    mov ah,9  
                ;function 9 of DOS interrupt 21h prints a string
    int 21h  
                ;terminates with a "$"
    mov ax,4c00h 
                ;returns control to DOS
    int 21h  
                ;must be here! If not, Program will crash!
main endp

end main


No comments:

Post a Comment