Implement console IO

This commit is contained in:
Juhani Krekelä 2021-09-10 19:39:58 +03:00
parent 24e82f0fcd
commit 9a7e047d57
1 changed files with 44 additions and 24 deletions

68
io.asm
View File

@ -27,19 +27,19 @@ org 0
; Jump table
jmp init ; 0000
jmp status ; 0003
jmp getch ; 0006
jmp putch ; 0009
jmp near ptr status ; 0003
jmp near ptr getch ; 0006
jmp near ptr putch ; 0009
jmp unimplemented ; 000c Output to printer
jmp unimplemented ; 000f Serial read
jmp unimplemented ; 0012 Serial write
jmp diskread ; 0015
jmp near ptr diskread ; 0015
jmp diskwrite ; 0018
jmp near ptr diskchange ; 001b
jmp setdate ; 001e
jmp settime ; 0021
jmp gettime ; 0024
jmp flush ; 0027
jmp near ptr flush ; 0027
jmp near ptr mapdev ; 002a
init:
@ -98,23 +98,33 @@ init:
; al = character if any
; zf = there were no characters
status proc far
push bx
push ax
mov ax, 0e00h + 's'
int 10h
mov ah, 1
int 16h
mov bl, al
pop ax
call far_caller
; TODO: Implement
xor ax, ax
test ax, ax
mov al, bl
pop bx
ret
status endp
getch:
mov al, 'g'
jmp error
; OUT:
; al = character
getch proc far
push bx
push ax
xor ah, ah
int 16h
mov bl, al
pop ax
mov al, bl
pop bx
ret
getch endp
; IN:
; ax = character
; al = character
putch proc far
push ax
mov ah, 0eh
@ -290,17 +300,27 @@ settime:
gettime:
mov al, 'T'
jmp error
flush:
mov al, 'f'
jmp error
flush proc far
push ax
flush_loop:
mov ah, 1
int 16h
jz flush_ret
xor ah, ah
int 16h
jmp flush_loop
flush_ret:
pop ax
ret
flush endp
mapdev proc far
push ax
mov ax, 0e00h + 'm'
int 10h
pop ax
call far_caller
; TODO: Figure out if this does anything?
; TODO: Implement
xor al, al
ret
mapdev endp