![放置引导文件不起作用](https://linux22.com/image/169902/%E6%94%BE%E7%BD%AE%E5%BC%95%E5%AF%BC%E6%96%87%E4%BB%B6%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我在 x86 上创建了以下程序集文件:
mov ah, 0x0e
mov al, 'H'
int 0x10
mov al, 'e'
int 0x10
mov al, 'l'
int 0x10
int 0x10 ; 'l' is still on al, remember?
mov al, 'o'
int 0x10
jmp $ ; jump to current address = infinite loop
; padding and magic number
times 510 - ($-$$) db 0
dw 0xaa55
我使用 nasm 编译:
nasm -f bin boot_sect_simple.asm -o boot_sect_hello.bin
并使用 qemu 测试了二进制文件:
qemu-system-x86_64 boot_sect_hello.bin
然后我将dd
二进制文件写入 U 盘的启动部分:
sudo dd if=/Users/niclas/assembly/OS/boot_sect_hello.bin of=/dev/disk2
然后我测试了正确性后:
sudo dd if=/dev/disk2 of=/dev/stdout bs=512 count=1 | hexdump
0000000 b4 0e b0 48 cd 10 b0 65 cd 10 b0 6c cd 10 cd 10
0000010 b0 6f cd 10 eb fe 00 00 00 00 00 00 00 00 00 00
0000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
00001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
0000200
看来是对的...
然而,试图在现代机器的启动菜单中找到例程似乎不起作用...... UEFI 找不到棒。我做错了什么?
免责声明:这是一个 UNIX 问题,因为我使用 Unix 和 Unixlike 系统来使其可启动......