我正在制作自定义操作系统。我有两个NASM文件:OS的引导加载程序不起作用
boot.asm:
[BITS 16] ;tell the assembler that its a 16 bit code
[ORG 0x7C00] ;Origin, tell the assembler that where the code will
;be in memory after it is been loaded
INT 0x13
JMP $ ;infinite loop
TIMES 510 - ($ - $$) db 0 ;fill the rest of sector with 0
DW 0xAA55 ; add boot signature
start.asm:
[BITS 16]
MOV AL, 72
CALL PrintCharacter
MOV AL, 101
CALL PrintCharacter
MOV AL, 108
CALL PrintCharacter
MOV AL, 108
CALL PrintCharacter
MOV AL, 111
CALL PrintCharacter
MOV AL, 44
CALL PrintCharacter
MOV AL, 32
CALL PrintCharacter
MOV AL, 87
CALL PrintCharacter
MOV AL, 111
CALL PrintCharacter
MOV AL, 114
CALL PrintCharacter
MOV AL, 108
CALL PrintCharacter
MOV AL, 100
CALL PrintCharacter
MOV AL, 33
CALL PrintCharacter
PrintCharacter:
MOV AH, 0x0E
MOV BH, 0x00
MOV BL, 0x07
INT 0x10
RET
TIMES 512 - ($ - $$) db 0
我编译他们到使用这些命令.bin文件:
nasm boot.asm -f bin -o boot.bin
nasm start.asm -f bin -o start.bin
然后用这些命令将它们添加到软盘映像中:
dd if=boot.bin bs=512 of=MyOS.img count=1
dd if=start.bin bs=512 of=MyOS.img count=2
当我从VirtualBox中的软盘映像启动时,它显示2个感叹号而不是一个,它甚至不能在QEmu(Q.app)中启动。我是操作系统开发新手,所以如果有人能告诉我我做错了什么并给我一些关于如何更好地设置我的操作系统的指导,那将是非常好的。
谢谢。我将无限循环移至start.asm,现在它工作。但是QEmu仍然无法启动。 – None 2010-07-20 01:37:59
我不了解QEMU。我只能猜测:也许你的第一条指令('INT 0x13h')是罪魁祸首。可能是因为QEMU的寄存器在启动时设置不同,并且中断调用不能满足您的需求。尝试明确设置寄存器('AH = 02,AL = 01,...')。或者QEMU没有模拟你的软盘驱动器,因此无法加载你的启动程序。 - 我必须承认,我不明白你在'boot.asm'中究竟做了什么。你不应该加载'start.asm'到内存中,然后*跳转*到它吗? – stakx 2010-07-20 09:02:15
当我将boot.asm的主要内容放在boot.asm中时,它工作正常。 – None 2010-07-20 18:22:01