commit 19e1a34d5f5524ce8c6d818c49dfdebf11685575
parent 92cc0d887b6f2aa9657545a4fbb44d5b14ceff49
Author: Stefan <misc@stefan-koch.name>
Date: Fri, 9 Oct 2015 20:38:51 +0200
simple bootloader displaying Hello world
Diffstat:
6 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -27,6 +27,7 @@
*.i*86
*.x86_64
*.hex
+*.bin
# Debug files
*.dSYM/
diff --git a/Makefile b/Makefile
@@ -0,0 +1,8 @@
+ASM = nasm
+ASMFLAGS =
+
+all: $(ASM_FILES)
+ $(ASM) $(ASMFLAGS) boot.asm -o boot.bin
+
+clean:
+ rm boot.bin
diff --git a/README.md b/README.md
@@ -1,2 +1,11 @@
# sos
Code for my operating system development (restarted since I forgot too much :)
+
+## Requirements
+You need to install bochs into your home directory under `~/opt/bochs`,
+so that its binary is accessible under `~/opt/bochs/bin/bochs`.
+
+For compiling the ASM files, you'll need `nasm`.
+
+## Compiling
+To compile, call `make`.
diff --git a/bochsrc b/bochsrc
@@ -0,0 +1,6 @@
+romimage: file="$HOME/opt/bochs/share/bochs/BIOS-bochs-latest"
+vgaromimage: file="$HOME/opt/bochs/share/bochs/VGABIOS-elpin-2.40"
+boot: floppy
+floppya: 1_44="boot.bin", status=inserted
+cpu: count=1, ips=4000000, reset_on_triple_fault=0
+magic_break: enabled=1
diff --git a/boot.asm b/boot.asm
@@ -0,0 +1,28 @@
+[BITS 16]
+[ORG 0x7C00]
+
+xor ax, ax ; set ax to 0 = first segment
+mov ss, ax
+mov ds, ax
+mov es, ax
+
+mov si, welcome_msg
+call print_string
+
+jmp $
+
+print_string:
+ mov ah, 0eh ; output with interrupt 10h
+.next_char:
+ lodsb ; reads one bytes and saves it to AL
+ cmp al, 0 ; was the nullbyte read?
+ je .done ; if yes: finished
+ int 10h ; otherwise: show current character from AL
+ jmp .next_char ; and go on with next char
+.done:
+ ret
+
+welcome_msg db 'Hello World!', 0
+
+times 510-($-$$) hlt
+dw 0xAA55
diff --git a/run_bochs.sh b/run_bochs.sh
@@ -0,0 +1 @@
+$HOME/opt/bochs/bin/bochs -f bochsrc