From 14fcc32d790f19f02e24b3393952af4bcd9890e5 Mon Sep 17 00:00:00 2001 From: Xnoe Date: Sun, 29 Aug 2021 21:50:27 +0100 Subject: [PATCH] Added interrupt handler --- hello.asm | 26 +++++--------------------- kernel.asm | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/hello.asm b/hello.asm index c4b3cd1..cbbca8b 100644 --- a/hello.asm +++ b/hello.asm @@ -2,28 +2,12 @@ mov ax, 3000h mov ds, ax push hello_world_str -call print - -;jmp $ +mov ah, 01h +int 22h retf -; print(str) -print: - push bp - mov bp, sp - mov si, [bp + 4] - mov ah, 0eh - mov cx, 1 - mov bh, 0 -print_loop: - lodsb - cmp al, 0 - je print_exit - int 10h - jmp print_loop -print_exit: - pop bp - ret 2 +hello_world_str db "Hello, World!", 13, 10, 13, 10, 0 -hello_world_str db "Hello, World!", 13, 10, 13, 10, 0 \ No newline at end of file +buffer: + times 32 db 0 \ No newline at end of file diff --git a/kernel.asm b/kernel.asm index 4b904d6..d8048a3 100644 --- a/kernel.asm +++ b/kernel.asm @@ -1,9 +1,16 @@ [BITS 16] + ; Update the IVT with our interrupt handler + mov bx, 0 + mov ds, bx + mov word [ds:136], ihdlr + mov word [ds:138], cs + mov ax, 2000h mov ds, ax pop ax mov byte [bootdisk], al + ; Set up kernel specifics ; Root Directory Entries will be at 2000h:2000h @@ -364,4 +371,28 @@ decode_filename_final: ret 2 _decode_buffer: - times 11 db 0 \ No newline at end of file + times 11 db 0 + +ihdlr: + pop word [_ihdlr_stack0] + pop word [_ihdlr_stack1] + pop word [_ihdlr_stack2] + + cmp ah, 01h + jne _ihdlr_2 + call print +_ihdlr_2: + cmp ah, 02h + jne _ihdlr_3 + call readline +_ihdlr_3: + + + push word [_ihdlr_stack2] + push word [_ihdlr_stack1] + push word [_ihdlr_stack0] + iret + +_ihdlr_stack0 dw 0 +_ihdlr_stack1 dw 0 +_ihdlr_stack2 dw 0 \ No newline at end of file