76 lines
914 B
Markdown
76 lines
914 B
Markdown
# bootloader
|
|
|
|
A tiny 32-bit x86 operating system kernel
|
|
|
|
http://3zanders.co.uk/2017/10/13/writing-a-bootloader/
|
|
|
|
## Real Mode Boot 1
|
|
|
|
16-bit mode.
|
|
|
|
Assemble with
|
|
|
|
``` shell
|
|
nasm -f bin boot1.asm -o boot1.bin
|
|
```
|
|
|
|
Run with
|
|
|
|
``` shell
|
|
qemu-system-x86_64 -fda boot1.bin
|
|
```
|
|
|
|
## Protected Mode Boot 2
|
|
|
|
32-bit mode.
|
|
|
|
Assemble with
|
|
|
|
``` shell
|
|
nasm -f bin boot2.asm -o bin2.bin
|
|
```
|
|
|
|
Run with
|
|
|
|
``` shell
|
|
qemu-system-x86_64 -fda boot2.bin
|
|
```
|
|
|
|
## Extended Boot 3
|
|
|
|
32-bit, 1024 byte.
|
|
|
|
Assemble with
|
|
|
|
``` shell
|
|
nasm -f bin boot3.asm -o boot3.bin
|
|
```
|
|
|
|
Run with
|
|
|
|
``` shell
|
|
qemu-system-x86_64 -fda boot3.bin
|
|
```
|
|
|
|
## Linking with Zig
|
|
|
|
32-bit, 1024 byte, building and linking in Zig code.
|
|
|
|
Build with
|
|
|
|
``` shell
|
|
zig build-exe boot4.o fun.zig -T linker.ld -nostdlib -target x86-freestanding
|
|
```
|
|
|
|
Convert to raw binary (strip ELF)
|
|
|
|
```shell
|
|
objcopy -Obinary fun fun.bin
|
|
```
|
|
|
|
|
|
Run with
|
|
|
|
``` shell
|
|
qemu-system-x86_64 -fda fun.bin
|
|
```
|