From 4150ef90ef790cf1ca43ca93f5432ea5482ce6b6 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Thu, 14 Mar 2019 16:17:02 +0000 Subject: [PATCH] Start IVT handling, create debug IR as example user --- dumpreg.asm => debug.asm | 7 +++++-- intr.asm | 21 +++++++++++++++++++++ main.asm | 24 ++++++++++-------------- 3 files changed, 36 insertions(+), 16 deletions(-) rename dumpreg.asm => debug.asm (71%) create mode 100644 intr.asm diff --git a/dumpreg.asm b/debug.asm similarity index 71% rename from dumpreg.asm rename to debug.asm index 213bc63..261a902 100644 --- a/dumpreg.asm +++ b/debug.asm @@ -1,5 +1,8 @@ +cpu 8086 + ; this kprints registers -_int_2F: +; expect to be called as interrupt routine +debug_reg_ir: push ss push es push ds @@ -30,4 +33,4 @@ _int_2F: pop ss iret .fmt: - db "AX=%X BX=%X CX=%X DX=%X SP=%X BP=%X SI=%X DI=%X", 0x0A, 0x0D, "DS=%X ES=%X SS=%X IP=%X CS=%X FL=%B", 0 + db "AX=%X BX=%X CX=%X DX=%X SP=%X BP=%X SI=%X DI=%X", 0x0A, 0x0D, "DS=%X ES=%X SS=%X IP=%X CS=%X FL=%X", 0 diff --git a/intr.asm b/intr.asm new file mode 100644 index 0000000..1eff611 --- /dev/null +++ b/intr.asm @@ -0,0 +1,21 @@ +cpu 8086 + +; set item in interrupt vector table +; in: bx interrupt number +; ds:dx new handler address +ivt_set: + push es + push ax + + xor ax,ax + mov es,ax + + sal bx,1 + sal bx,1 + + mov [es:bx], dx + mov [es:bx+2], ds + + pop ax + pop es + ret diff --git a/main.asm b/main.asm index e6fb94d..7c865f6 100644 --- a/main.asm +++ b/main.asm @@ -40,24 +40,20 @@ _exit: db "Halted: Waiting for poweroff...", 0 main: - mov ax,cs - mov ds,ax + mov ax, cs + mov ds, ax - sub sp, 0x30 + mov bx, 0x002E + mov dx, debug_reg_ir - xor ax,ax - mov es,ax - mov ax,_int_2F - xchg ax,[es:0x2F*4] - mov ax,cs - xchg ax,[es:0x2F*4+2] - int 0x2F - test ax, 0xFF - int 0x2F + call ivt_set - add sp, 0x30 + int 0x2E + cmp ax,0x55AA + int 0x2E ret -%include "dumpreg.asm" +%include "intr.asm" +%include "debug.asm" %include "kprintf.asm"