1
灌裝512字節我使用Bochs的模擬器來運行一個引導扇區,這在NASM編碼是這樣的:簡單的引導扇區代碼:0
org 07c00h ;told the compiler to load the code to 0x7c00h
mov ax, cs
mov ds, ax
mov es, ax
call DispStr ;call the string process
jmp $ ;infinite loop
DispStr:
mov ax, BootMessage
mov bp, ax ;ES:BP = string address
mov cx, 16 ;CX = length of the string
mov ax, 01301h ;AH = 13, AL = 01H
mov bx, 000ch ;(BH = 0)
mov dl, 0
int 10h ;10h interrupt
ret
BootMessage: db "Hello, OS world!" ;message printed
times 510-($-$$) db 0 ;fill the left of the 510 byte with 0
dw 0xaa55
如果times 510-($-$$) db 0
如果禁止的,有沒有另一種方法用0填充510字節區域的左側?
我試過循環命令,但無法正常工作。
_「如果時間510 - ($ - $$)db 0 if forbidden」_爲什麼會被禁止? – Michael
@Michael但是我們操作系統類的助手要求我們想出一個可選的方式來填補空白... – Stone
呵呵。聽起來像是浪費時間給我。這是一個OS類還是一個NASM指令類? – Michael