The first version uses a DOS interrupt function ah=2 to print a char, a loop, and array access of memory
.MODEL SMALL
.STACK 100
.DATA
Message db 'Hello, world',0
.CODE
s
tart:
mov ax,@data
mov ds,ax
;set DS to point to the data segment
mov ah,2
;DOS print char function
xor bx,bx
top: Mov dl , message[bx]
<
BR> cmp dl,0
Je alldone
int 21h
;display chars
Inc bx
Jmp top
alldone:
mov ax,04c00h
;DOS terminate program functio
n
int 21h
;terminate the program
END start
Version 2 Second version uses something like array addressing. The register BX can be used to point at memory as can SI, DI, BP. [BX] means "contents of location pointed to by BX", ie. address dereferencing. byte ptr [bx] means "get the byte at the address where bx points" (as opposed to the word, the double word, etc).
;;version 2
.MODEL SMALL
.STACK 100
.DATA
Message db 'Hello, world',0
.CODE
start:
mov ax,@data
mov ds,ax &nb
sp;
;set DS to point to the data segment
mov ah,2
;DOS print char function
Mov bx, offset message
top: Mov dl , byte ptr[bx]
cmp dl,0
Je alldone
int 21h &nbs
p;
;display chars
Inc bx
Jmp top
alldone:
mov ax,04c00h
;DOS terminate program function
int 21h &n
bsp;
;terminate the program
END start