我试图编写一个打印字符串函数;
45 ; the address is stored in si
46 print_string:
47 pusha
48 ; load character from si
49 mov al, [si]
50 cmp al, 0x00
51 jz print_string_end
52 call print_char ; print the char using the print_char function
53 inc si ; increment the string printing index si
54 print_string_end:
55 popa
56 ret
57
58 ; print function: print a single character
59 ; the character is stored in al
60 print_char:
61 pusha
62 mov ah, 0x0e
63 int 0x16
64 popa ; don't know what registers int 0x16 modifies
65 ret
66
67 mystring:
68 db "loading operating system",0x00
这将组装并运行。然而,在我改为使用之前
si
对于要打印的当前字符的地址,我正在使用寄存器
dx
。由于某种原因,从
硅
到
dx
导致以下nasm错误:
bootsector.asm:49: error: invalid effective address
为什么不
mov al, [dx]
工作,但是
mov al, [si]
做