我有这个程序,想要将字符串写到屏幕上,但是输出为空,我在每一行都添加了注释。
[org 0x7c00] ; Tell the assember the place to load this code
mov bx, HELLO_MSG ; move the data to the bx register
pusha ; push all register values to stack?
call printstr ; call printstr routine
printstr:
mov ah, 0x0e ; BIOS teletype output
pop bx ; pop to bx
mov al, bl ; put low byte of bx to al
int 0x10 ; print it.
cmp al, 0 ; Compare if its a string termination character?
jne printstr ; if not go back to top
ret ; return to the caller?
; Data
HELLO_MSG:
db 'Hello world!', 0
jmp $
times 510-($-$$) db 0
dw 0xaa55
POP BX
指令没有执行您似乎假定的操作。它从堆栈中获取一个值并将其存储在BX
中。它不访问BX
指向的内存。您需要类似MOV AL, [BX]
的内容来检索由BX
指向的字符,然后是使BX
指向下一个字符的指令。