diff --git a/Makefile b/Makefile index 10966d1..89f18d5 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ TARGET = foxdos FILES = config.s \ src/int21.s \ - src/kernel.s + src/kernel.s \ + src/vga.s .PHONY: all qemu clean all: obj/boot.o obj/kernel.o $(TARGET) diff --git a/config.s b/config.s index 5d830b2..511d33f 100644 --- a/config.s +++ b/config.s @@ -1,4 +1,4 @@ -NUMSEG equ 0 ; TODO build system should calculate this value +NUMSEG equ 1 ; TODO build system should calculate this value ; might be good to move one of these into the high memory area K_ADDR equ 0x500 ; kernel load address diff --git a/src/boot.s b/src/boot.s index ef1b0ee..eaac5a6 100644 --- a/src/boot.s +++ b/src/boot.s @@ -1,4 +1,4 @@ -; mothdos boot sector. should load kernel into segment 0x50 at 0x00. max size +; foxdos boot sector. should load kernel into segment 0x50 at 0x00. max size ; would be 64k but i doubt a dos needs more than that. stack is placed at ; 0x10500. i would suggest changing this to load the kernel into extended ; a20-gate memory so as not to overwrite the boot sector with larger kernels diff --git a/src/kernel.s b/src/kernel.s index 405553f..ebf0418 100644 --- a/src/kernel.s +++ b/src/kernel.s @@ -1,6 +1,12 @@ %include "config.s" -[org K_ADDR] + kernel_entry: ; MUST be a short jump due to loader config - jmp $ ; TODO stub because os doesnt actually exist yet + mov si, hello_string + mov bl, 0x70 + call print_string + jmp $ + +hello_string: db "hello world!", 13, 10, '$' %include "int21.s" +%include "vga.s" diff --git a/src/vga.s b/src/vga.s new file mode 100644 index 0000000..fbf1559 --- /dev/null +++ b/src/vga.s @@ -0,0 +1,46 @@ +; print a string to the screen +; inputs: +; DS:SI: pointer to '$'-terminated string +; BL: attribute +; outputs: +; none +print_string: + push ax + push bx + push cx + push dx + push bp + push es + + ; get cursor position in DX + mov ah, 0x03 + mov bh, 0x00 + int 0x10 + + ; calculate string length by iterating over it until we reach '$' + ; this sucks but we have to do it because the bios expects to be passed the string length directly + xor cx, cx + push si +.size_loop: + inc cx + inc si + cmp byte [si], '$' + jnz .size_loop + pop si + mov bp, si + + ; print string and update cursor position + mov ax, ds + mov es, ax + mov ah, 0x13 + mov al, 0x01 + mov bh, 0x00 + int 0x10 + + pop es + pop bp + pop dx + pop cx + pop bx + pop ax + ret