【发布时间】:2016-07-27 23:01:35
【问题描述】:
我使用 Bochs 模拟器运行引导扇区,在 NASM 中编码如下:
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字节区域的左侧?
我试过循环命令,但不能正常工作。
【问题讨论】:
-
"If times 510-($-$$) db 0 if disabled" 为什么会被禁止?
-
@Michael 但是我们操作系统课的助手让我们想出一个可选的方法来填补空白......
-
嗯。对我来说听起来像是在浪费时间。这是 OS 类还是 NASM 指令类?
-
一个使用 NASM 进行实验的 OS 类
-
助教在浪费你的时间。在 OS 开发类中,有比如何使用 rep 与 $-$$ 更重要的事情。