I have created the following assembly file on 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
I have compiled using nasm:
nasm -f bin boot_sect_simple.asm -o boot_sect_hello.bin
And tested the binary using qemu:
qemu-system-x86_64 boot_sect_hello.bin
Then I used dd
to write the binary to the boot section of my USB stick:
sudo dd if=/Users/niclas/assembly/OS/boot_sect_hello.bin of=/dev/disk2
I have then tested after correctness:
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
Seems right...
However, trying to find the routine in the boot menu of a modern machine does not seem to work... UEFI cannot find the stick. What have I done wrong?
Disclaimer: This is a UNIX question since I am using Unix and Unixlike Systems to make it bootable...