Here's the first version, which displays garbage before the Hello World message:
Code: Select all
; Update the segment registers
mov ax, cs
mov ds, ax
mov es, ax
HelloString db "Hello World",0
MOV SI, HelloString ;Store string pointer to SI
print:
LODSB ;AL=memory contents at DS:SI
OR AL, AL ;Check if value in AL is zero (end of string)
JZ loop ;If end then return
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
INT 0x10 ;Call video interrupt
JMP print ; Print next character
loop:
MOV AL, 'Z' ;I'll print a char to see that it ended
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
INT 0x10 ;Call video interrupt
JMP $ ;Infinite loop
Code: Select all
JMP beginningofprogram
print:
LODSB ;AL=memory contents at DS:SI
OR AL, AL ;Check if value in AL is zero (end of string)
JZ loop ;If end then return
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
INT 0x10 ;Call video interrupt
JMP print ; Print next character
beginningofprogram:
; Update the segment registers
mov ax, cs
mov ds, ax
mov es, ax
MOV SI, HelloString ;Store string pointer to SI
JMP print ; Print next character
loop:
MOV AL, 'Z' ;I'll print a char to see that it ended
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
INT 0x10 ;Call video interrupt
JMP $ ;Infinite loop
HelloString db "Hello World",0
Can anyone pick out the bug in either one of these programs? Thanks!