From 40065266f3e104082fca8c0d12c2bacd085ebd22 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Mon, 20 Apr 2020 19:13:06 +0200 Subject: [PATCH] Implement int 29h: Fast console output --- boot/kernel.asm | 50 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/boot/kernel.asm b/boot/kernel.asm index 482904b..7c94c61 100644 --- a/boot/kernel.asm +++ b/boot/kernel.asm @@ -6,7 +6,11 @@ banner: db "rdos", 0xA, 0xD, '$' + ; Alias for Int 21h,AH=0h int20h: xor ah, ah + ; allow extenders to get away with only hooking 21h + jmp [cs:(0x21 * 4)] + int21h: ; inside of kernel, direction always goes up ; the iret will restore it to the user value later cld @@ -30,7 +34,7 @@ int21h: ; inside of kernel, direction always goes up pop bp pop ax ; iret frame: IP CS FLAGS - iret +iret: iret ; Subfunction ptr ; this is used as extra register in int21h @@ -72,12 +76,10 @@ putc: push ax ; DOS 1+ 9h - WRITE STRING TO STANDARD OUTPUT ; IN ds:dx '$'-terminated string puts: push si - mov ah, 0x0E - xor bx, bx .loop: lodsb cmp al, '$' je .end - int 0x10 + int 0x29 jmp .loop .end: pop si ret @@ -202,11 +204,19 @@ ldbpb: push ds pop ds ret -main: mov si, banner - mov ah, 0x09 - int 0x21 -end: hlt - jmp end + ; DOS 2+ - FAST CONSOLE OUTPUT + ; IN al character to print +fputc: push ax + push bx + mov ah, 0x0E + xor bx, bx + int 0x10 + pop bx + pop ax + iret + +main: hlt + jmp main init: cli xor ax, ax @@ -220,14 +230,28 @@ init: cli mov cx, (init-$$) rep movsb + ; Set boot drive as current drive call dnconv call select + ; Set int 0x20 to 0x2F + mov bx, ivects+0x7C00-$$ + mov cx, 0x10 mov al, 0x20 - mov dx, int20h - call setint - mov al, 0x21 - mov dx, int21h +.loop: mov dx, [bx] call setint + inc al + inc bx + inc bx + loop .loop + + mov si, banner + mov ah, 0x09 + int 0x21 jmp 0:main + +ivects: dw int20h, int21h, iret, iret + dw iret, iret, iret, iret + dw iret, fputc, iret, iret + dw iret, iret, iret, iret