From d9affa3caecaa9531d109c7f2b953432ee0ae0a2 Mon Sep 17 00:00:00 2001 From: Nero <41307858+nero@users.noreply.github.com> Date: Tue, 20 Apr 2021 16:27:10 +0000 Subject: [PATCH] Kernel: Fix segmenting bugs --- com/@rdos.asm | 9 +++++++-- kernel/far.asm | 12 ++++++++++++ rom/uartctrl.asm | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/com/@rdos.asm b/com/@rdos.asm index f3fb108..83e817a 100644 --- a/com/@rdos.asm +++ b/com/@rdos.asm @@ -23,15 +23,20 @@ init: call rstseg call rstseg mov dx, testdta + push ds + call norm call setdta + pop ds + mov dx, testfcb + call norm call open - int 3 - call read + mov ax, [cs:testdta] + mov cx, [cs:testdta+2] int 3 hlt: hlt diff --git a/kernel/far.asm b/kernel/far.asm index 239cd2b..a799241 100644 --- a/kernel/far.asm +++ b/kernel/far.asm @@ -32,3 +32,15 @@ xchgdes push ds pop ds pop es ret + + ; normalize ptr in ds:dx +norm mov ax, ds + mov cl, 4 + push dx + ror dx, cl + and dh, 0xF + add ax, dx + mov ds, ax + pop dx + and dx, 0xF + ret diff --git a/rom/uartctrl.asm b/rom/uartctrl.asm index b5bd775..ae0ced3 100644 --- a/rom/uartctrl.asm +++ b/rom/uartctrl.asm @@ -77,6 +77,10 @@ init push ax mov al, 8 out dx, al + ; DS = interrupt table + xor ax, ax + mov ds, ax + ; hook video services ; keep original ptr in intvec 47h for chaining mov ax, int10