Implement some console i/o

This commit is contained in:
Nero 2020-04-23 21:35:28 +02:00
parent 035b69db10
commit 3619a20703

View File

@ -41,8 +41,8 @@ iret: iret
sfptr: dw 0 sfptr: dw 0
; Subfunction table ; Subfunction table
sftab: dw sferr, sferr, putc, sferr sftab: dw sferr, getc, putc, sferr
dw sferr, sferr, sferr, sferr dw sferr, sferr, conout, conin
dw sferr, puts, sferr, sferr dw sferr, puts, sferr, sferr
dw sferr, sferr, sferr, sferr dw sferr, sferr, sferr, sferr
; 10 ; 10
@ -61,18 +61,56 @@ sftab: dw sferr, sferr, putc, sferr
dw sferr, sferr, sferr, sferr dw sferr, sferr, sferr, 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 ; IN dl character to write
putc: push ax putc: push ax
push bx
mov ah, 0x0E
mov al, dl mov al, dl
xor bx, bx .2: int 0x29
int 0x10
pop bx
pop ax pop ax
ret 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 ; DOS 1+ 9h - WRITE STRING TO STANDARD OUTPUT
; IN ds:dx '$'-terminated string ; IN ds:dx '$'-terminated string
puts: push si puts: push si