aboutsummaryrefslogtreecommitdiff
path: root/mubios
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-11-08 06:56:33 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-11-08 06:56:33 +0800
commita460aa2fd50ba86f39e7d23ff3019aedd2b8600e (patch)
treeccd47150f922bf0a5be8469d65f50a6ed2a41512 /mubios
parent58e9f8a9c7f63e500a20c7ee15ee7c67a3f90abc (diff)
downloadrcc-project-a460aa2fd50ba86f39e7d23ff3019aedd2b8600e.tar.gz
rcc-project-a460aa2fd50ba86f39e7d23ff3019aedd2b8600e.tar.xz
[mubios] Implement a minimal INT 10h AH=0Eh
Signed-off-by: Richard Qin <richard.qin.x@gmail.com>
Diffstat (limited to 'mubios')
-rw-r--r--mubios/arch/interrupt.S92
-rw-r--r--mubios/core/bda.c2
2 files changed, 94 insertions, 0 deletions
diff --git a/mubios/arch/interrupt.S b/mubios/arch/interrupt.S
index 7cb3f4b..6dc05c8 100644
--- a/mubios/arch/interrupt.S
+++ b/mubios/arch/interrupt.S
@@ -48,3 +48,95 @@ int1a_entry:
int1a_return:
iret
+
+ .global int10_entry
+ .type int10_entry, @function
+
+int10_entry:
+ cmp ah, 0x0E
+ jne int10_return
+
+ push bp
+ mov bp, sp
+
+ push ax
+ push bx
+ push dx
+ push si
+ push di
+ push ds
+ push es
+
+ xor ax, ax
+ mov ds, ax
+
+ mov ax, 0xB800
+ mov es, ax
+
+ mov si, 0x0050
+ mov dx, word ptr [si]
+
+ mov al, byte ptr [bp - 2]
+ mov bl, byte ptr [bp - 4]
+
+ cmp al, 0x0D
+ je int10_carriage_return
+
+ cmp al, 0x0A
+ je int10_line_feed
+
+ cmp al, 0x08
+ je int10_backspace
+
+ mov di, dx
+ shl di, 1
+ mov ah, bl
+ mov word ptr es:[di], ax
+ inc dx
+ jmp int10_store_cursor
+
+
+int10_carriage_return:
+ mov ax, dx
+ mov si, 80
+ xor dx, dx
+ div si
+ mul si
+ mov dx, ax
+ jmp int10_store_cursor
+
+int10_line_feed:
+ add dx, 80
+ jmp int10_store_cursor
+
+int10_backspace:
+ cmp dx, 0
+ je int10_store_cursor
+
+ dec dx
+ mov di, dx
+ shl di, 1
+ mov al, 0x20
+ mov ah, bl
+ mov word ptr es:[di], ax
+
+int10_store_cursor:
+ cmp dx, 2000
+ jb int10_save_cursor
+
+ xor dx, dx
+
+int10_save_cursor:
+ mov word ptr [0x0050], dx
+
+ pop es
+ pop ds
+ pop di
+ pop si
+ pop dx
+ pop bx
+ pop ax
+ pop bp
+
+int10_return:
+ iret
diff --git a/mubios/core/bda.c b/mubios/core/bda.c
index 5fae081..494c093 100644
--- a/mubios/core/bda.c
+++ b/mubios/core/bda.c
@@ -57,6 +57,7 @@ extern void irq0_entry (void);
extern void irq1_entry (void);
extern void int1a_entry (void);
+extern void int10_entry (void);
static void
install_ivt_entry (u8 vector, void (*handler) (void))
@@ -79,4 +80,5 @@ ivt_init (void)
install_ivt_entry (0x08u, irq0_entry);
install_ivt_entry (0x09u, irq1_entry);
install_ivt_entry (0x1Au, int1a_entry);
+ install_ivt_entry (0x10u, int10_entry);
}