Continued development on int 21h interface

This commit is contained in:
Nero 2021-01-03 18:11:41 +00:00
parent 3f8cfaac42
commit fb4bbfc8cf
3 changed files with 55 additions and 15 deletions

View File

@ -35,8 +35,9 @@ init: cli
mov word [0x21*4+2], cs
mov word [curpsp], 0x1000
mov ah, 2
mov dl, 0x37
mov ah, 2
int 0x21
int 0x21
restart:

View File

@ -10,14 +10,17 @@ absolute 0
resb 1
resb 5 ; CP/M entry point
; SS:SP, DS:DX, ES:BX and AX from the program
; saved userdata
PSPAX: resw 1
PSPSS: resw 1
; SS:SP
PSPSP: resw 1
PSPDS: resw 1
PSPDX: resw 1
PSPSS: resw 1
; DS:DX
PSPDX: resw 1
PSPDS: resw 1
; ES:BX
PSPBX: resw 1
PSPES: resw 1
PSPBX: resd 1
section .text
@ -49,9 +52,25 @@ int21: push ds
call .etbl
; syscall table
; cells: ptr to handler, ptr to sysret
; 0-7
dw restart, sret
dw getc, sretb
dw putc, sret
dw err, sret ; reader input
dw err, sret ; punch outout
dw err, sret ; list output
dw conio, sret ; direct console i/o
dw err, sret
; 8-f
dw err, sret
dw err, sret ; print string
dw err, sret ; read into buffer
dw err, sret ; console status
dw err, sret ; return version num
dw err, sret ; reset disks
dw err, sret ; select disk
dw err, sret ; open file
; set up a return chain and execute it
; first return into handler function
; second return into appropiate sysret
@ -61,26 +80,27 @@ int21: push ds
push word [cs:bx]
ret
err: mov ah, 0xFF
ret
; sysret handlers
; return ES:BX to user
sretd: call pspds
sretd: mov ds, [ss:curpsp]
jmp sret.l02
; return BX to user
sretw: call pspds
sretw: mov ds, [ss:curpsp]
mov es, [PSPES]
jmp sret.l02
; return AL to user
sretb: push ax
call pspds
pop ax
sretb: mov ds, [ss:curpsp]
mov ah, [PSPAX+1]
les bx, [PSPBX]
jmp sret.l03
; return without result
sret: call pspds
sret: mov ds, [ss:curpsp]
.l01: les bx, [PSPBX]
.l02: mov ax, [PSPAX]
.l03: mov ss, [PSPSS]

View File

@ -1,11 +1,30 @@
getc: xor ax, ax
int 0x16
section .text
getc: call conin
test al, al
jz getc
ret
putc: mov al, dl
putc: ; flag checking here
conout: mov al, dl
mov ah, 0x0e
xor bx, bx
int 0x10
ret
conio: cmp dl, 0xFF
jne conout
conin: call const
test al, al
jz .ret
mov al, 0
int 0x16
.ret: ret
const: mov ah, 1
int 0x16
jz .emp
.rdy: mov ax, 0xFF
ret
.emp: mov al, 0
ret