3 ms·
Show HN: An HelloWorld x86-Bootloader
- smoppi 5y agoA hello world for an IBM PC compatible does not require much. Sadly UEFI has made everything exponentially more complex. If you want to be more minimalistic, this also works with if the BIOS is newer than 1/10/86 (written in NASM syntax): [org 0x7c00] ; code offset xor dx, dx ; row 0, col 0 mov ds, dx ; set data segment to 0 mov ax, 0x1300 ; ah = 0x13 (write string), al = 0x00 (write mode) mov bx, 0x0007 ; bh = video page number (0), bl = attribute byte mov cx, 11 ; string len: 11 bytes mov es, dx ; ES:BP = pointer to string mov bp, message int 0x10 ; interrupt 0x10 end: ; do nothing to prevent crashing jmp end ; (cli & hlt also works) message: db "Hello world" times 0x01FE-($-$$) db 0 ; padding dw 0xAA55 ; boot sector signature
- sim7c00 5y agoloved getting into this stuff, still making my own os years later (dreamy project...). Want to say there's so many things wrong with small examples like this, despite the examples themselves being wonderful like this one. For example, most don't include a partition table, which is needed if you use AHCI controller instead of IDE. (so depending on your hardware of vm/emu configuration it won't work at all)