Add changes related to c implementation, printf

This commit is contained in:
Allen
2024-09-15 22:59:06 -05:00
parent 773c99727a
commit 9f4222e84f
16 changed files with 608 additions and 0 deletions

14
src/kernel/Makefile Normal file

@ -0,0 +1,14 @@
BUILD_DIR?=build/
ASM?=nasm
.PHONY: all kernel clean
all: kernel
kernel: $(BUILD_DIR)/kernel.bin
$(BUILD_DIR)/kernel.bin:
$(ASM) kernel.asm -f bin -o $(BUILD_DIR)/kernel.bin
clean:
rm -f $(BUILD_DIR)/kernel.bin

43
src/kernel/kernel.asm Normal file

@ -0,0 +1,43 @@
org 0x0 ; kernel loaded with 0 offset
bits 16 ; emit 16-bit code
%define ENDL 0X0D, 0xA ; CRLF
start:
; print message
mov si, msg_hello ; set si to point to msg_hello
call puts ; call puts with si
.halt:
cli
hlt
; Prints string to screen
; Params:
; ds:si - pointer to string
puts:
push si
push ax
push bx
.loop:
lodsb ; load byte from ds:si into al, increment si
or al, al ; set zero flag if al is 0
jz .done ; jump to done if al is 0
mov ah , 0x0E ; enter tty mode
mov bh, 0 ; page number
int 0x10 ; call BIOS interrupt
jmp .loop ; jump back to loop
.done:
pop bx
pop ax
pop si
ret
msg_hello: db 'Hello from chaOS!', ENDL, 0