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 [0x21*4+2], cs
mov word [curpsp], 0x1000 mov word [curpsp], 0x1000
mov ah, 2
mov dl, 0x37 mov dl, 0x37
mov ah, 2
int 0x21
int 0x21 int 0x21
restart: restart:

View File

@ -10,14 +10,17 @@ absolute 0
resb 1 resb 1
resb 5 ; CP/M entry point resb 5 ; CP/M entry point
; SS:SP, DS:DX, ES:BX and AX from the program ; saved userdata
PSPAX: resw 1 PSPAX: resw 1
PSPSS: resw 1 ; SS:SP
PSPSP: resw 1 PSPSP: resw 1
PSPDS: resw 1 PSPSS: resw 1
PSPDX: resw 1 ; DS:DX
PSPDX: resw 1
PSPDS: resw 1
; ES:BX
PSPBX: resw 1
PSPES: resw 1 PSPES: resw 1
PSPBX: resd 1
section .text section .text
@ -49,9 +52,25 @@ int21: push ds
call .etbl call .etbl
; syscall table ; syscall table
; cells: ptr to handler, ptr to sysret ; cells: ptr to handler, ptr to sysret
; 0-7
dw restart, sret dw restart, sret
dw getc, sretb dw getc, sretb
dw putc, sret 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 ; set up a return chain and execute it
; first return into handler function ; first return into handler function
; second return into appropiate sysret ; second return into appropiate sysret
@ -61,26 +80,27 @@ int21: push ds
push word [cs:bx] push word [cs:bx]
ret ret
err: mov ah, 0xFF
ret
; sysret handlers ; sysret handlers
; return ES:BX to user ; return ES:BX to user
sretd: call pspds sretd: mov ds, [ss:curpsp]
jmp sret.l02 jmp sret.l02
; return BX to user ; return BX to user
sretw: call pspds sretw: mov ds, [ss:curpsp]
mov es, [PSPES] mov es, [PSPES]
jmp sret.l02 jmp sret.l02
; return AL to user ; return AL to user
sretb: push ax sretb: mov ds, [ss:curpsp]
call pspds
pop ax
mov ah, [PSPAX+1] mov ah, [PSPAX+1]
les bx, [PSPBX] les bx, [PSPBX]
jmp sret.l03 jmp sret.l03
; return without result ; return without result
sret: call pspds sret: mov ds, [ss:curpsp]
.l01: les bx, [PSPBX] .l01: les bx, [PSPBX]
.l02: mov ax, [PSPAX] .l02: mov ax, [PSPAX]
.l03: mov ss, [PSPSS] .l03: mov ss, [PSPSS]

View File

@ -1,11 +1,30 @@
getc: xor ax, ax section .text
int 0x16
getc: call conin
test al, al test al, al
jz getc jz getc
ret ret
putc: mov al, dl putc: ; flag checking here
conout: mov al, dl
mov ah, 0x0e mov ah, 0x0e
xor bx, bx xor bx, bx
int 0x10 int 0x10
ret 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