我的期望是打印一個字符串,但沒有打印出來。 當我縮短字符串時,它有時會起作用,當我再次使它們變長時,它有時會起作用。爲什麼這個引導加載程序代碼不起作用?
我不知道爲什麼這不起作用。
有人能幫助我嗎? 謝謝。
我使用的組件,代碼是:
(Emacs的23,的Ubuntu 10.10,NASM,VirtualBox的OSE)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 0x7c00
bits 16
str:
db "Some say the world will end in fire",10,13
db "Some say in ice",10,13
db "From what I've tasted of desire",10,13
db "I hold with those who favor fire",10,13
db "But if I had to perish twice,",10,13
db "I think I know enough of hate",10,13
db "To say that for destruction ice",10,13
db "is also great and would suffice."
db "Robert Frost - Fire and Ice"
db 0
start:
xor ax,ax
mov ds,ax
mov es,ax
mov si, str
xor bx,bx
mov ah, 0x0e
print:
lodsb ;al = current char
cmp al, 0
je end
int 0x10
jmp print
end:
cli
hlt
times 510 - ($-$$) db 0
dw 0xAA55
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
我想你需要添加一個CLD指令,以確保lodsb增加si,並且不會減少它。不過,我認爲還有其他一些問題。 – 2011-04-18 07:05:29