Add changes related to c implementation, printf
This commit is contained in:
14
src/kernel/Makefile
Normal file
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
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
|
Reference in New Issue
Block a user