我知道这个问题以前曾被问过,但其他答案似乎都没有解决我的问题。也许我错过了什么?引导加载程序在实际的计算机上无法正常工作
我知道.iso的作品,因为我在QEMU中运行它,并成功运行。那么我做错了什么?
bits 16
xor ax, ax
start:
cld ; Set direction flag to forward
; Set up registers
mov ax, 07c0h ; Segment location which BIOS loads
add ax, 288 ; (4096 + 512)/16 bytes
mov ss, ax ; Sets stack segment register
mov sp, 4096 ; Sets stack pointer register (offset of stack)
mov ax, 07c0h
mov ds, ax ; Sets data segment to where we're loaded
mov si, text ; Puts string into source index
call print_string ; Calls print string
jmp $ ; Infinite loop to prevent shutdown
print_string:
mov ah, 0eh ; System call for printing
xor bh, bh ; Sets BH register to 0
.repeat:
lodsb ; Loads byte into AL
cmp al, 0 ; Sees if AL is 0
je .done ; Jumps to done if AL is zero
int 10h ; Otherwise, print
jmp .repeat ; Repeat
.done:
ret
text db 'Test', 0
times 510 - ($ - $$) db 0 ; Pads 510 - (current location - start location) zeros
dw 0xAA55 ; Standard PC boot signature (takes up 2 bytes)
编辑:我已经添加了以下我的代码:
xor ax, ax
cld
xor bh, bh
用于创建ISO,我运行以下命令:
dd if=/dev/zero of=floppy.img bs=1024 count=1440
dd if=bootloader.bin of=floppy.img seek=0 count=1 conv=notrunc
mkdir iso
cp floppy.img iso/
mkisofs -o file.iso -b floppy.img iso
刻录的iso我usb,我运行以下命令:
umount /dev/sdX
dd if=/home/mint/Downloads/file.iso of=/dev/sdX bs=4M && sync
你究竟在做什么来启动你的“.iso”在实际的计算机上? –
您可能希望使用_CLD_向前设置方向标志,因为您依靠_LODSB_的向前方向。在达到coe之前,您无法保证BIOS设定了什么方向。 –
对于[Int 10h/ah = 0eh](http://www.ctyme.com/intr/rb-0106.htm),您可能希望将BH寄存器设置为0,因为该寄存器用作要写入的页码。 –