Hello world :3
This commit is contained in:
parent
5efa40dc9b
commit
3971b4602f
3
Makefile
3
Makefile
|
@ -2,7 +2,8 @@ TARGET = foxdos
|
||||||
|
|
||||||
FILES = config.s \
|
FILES = config.s \
|
||||||
src/int21.s \
|
src/int21.s \
|
||||||
src/kernel.s
|
src/kernel.s \
|
||||||
|
src/vga.s
|
||||||
|
|
||||||
.PHONY: all qemu clean
|
.PHONY: all qemu clean
|
||||||
all: obj/boot.o obj/kernel.o $(TARGET)
|
all: obj/boot.o obj/kernel.o $(TARGET)
|
||||||
|
|
2
config.s
2
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
|
; might be good to move one of these into the high memory area
|
||||||
K_ADDR equ 0x500 ; kernel load address
|
K_ADDR equ 0x500 ; kernel load address
|
||||||
|
|
|
@ -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
|
; 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
|
; 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
|
; a20-gate memory so as not to overwrite the boot sector with larger kernels
|
||||||
|
|
10
src/kernel.s
10
src/kernel.s
|
@ -1,6 +1,12 @@
|
||||||
%include "config.s"
|
%include "config.s"
|
||||||
[org K_ADDR]
|
|
||||||
kernel_entry: ; MUST be a short jump due to loader config
|
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 "int21.s"
|
||||||
|
%include "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
|
Loading…
Reference in New Issue