From 3619a20703bc599f3f63ff797d6a570137092386 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Thu, 23 Apr 2020 21:35:28 +0200 Subject: [PATCH] Implement some console i/o --- boot/kernel.asm | 54 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/boot/kernel.asm b/boot/kernel.asm index f971134..4f5fd03 100644 --- a/boot/kernel.asm +++ b/boot/kernel.asm @@ -41,8 +41,8 @@ iret: iret sfptr: dw 0 ; Subfunction table -sftab: dw sferr, sferr, putc, sferr - dw sferr, sferr, sferr, sferr +sftab: dw sferr, getc, putc, sferr + dw sferr, sferr, conout, conin dw sferr, puts, sferr, sferr dw sferr, sferr, sferr, sferr ; 10 @@ -61,18 +61,56 @@ sftab: dw sferr, sferr, putc, sferr dw sferr, sferr, sferr, sferr dw sferr, sferr, sferr, sferr - ; DOS 1+ 2h - WRITE CHARACTER TO STANDARD OUTPUT + ; OUT al character read +getc: xor ax, ax + int 0x16 + push ax + jmp putc.2 + ; IN dl character to write putc: push ax - push bx - mov ah, 0x0E mov al, dl - xor bx, bx - int 0x10 - pop bx +.2: int 0x29 pop ax ret + ; console output + ; IN dl character +conout: cmp dl, 0xFF + je conine + push ax + mov al, dl + int 0x29 + pop ax + ret + + ; console input with echo + ; OUT al character + ; zf clear when character available +conine: mov ah, 1 + int 0x16 + jnz .has + xor al, al + ret +.has: xor ax, ax + int 0x16 + int 0x29 + test ax, ax + ret + + ; console input without echo + ; OUT al character + ; zf clear when character available +conin: mov ah, 1 + int 0x16 + jnz .has + xor al, al + ret +.has: xor ax, ax + int 0x16 + test ax, ax + ret + ; DOS 1+ 9h - WRITE STRING TO STANDARD OUTPUT ; IN ds:dx '$'-terminated string puts: push si