PoC CBIOS

This commit is contained in:
Nero 2019-10-24 23:11:19 +00:00
parent 6e2b65e9c0
commit a016fb0981

142
bios/8086.asm Normal file
View File

@ -0,0 +1,142 @@
ORG (RAM-0x600)
CPU 8086
DISKCX: EQU 0x40
DISKDL: EQU 0x42
DISKDH: EQU 0x43
DISKBX: EQU 0x44
JMP NEAR BOOT
JMP NEAR WBOOT
JMP NEAR CONST
JMP NEAR CONIN
JMP NEAR CONOUT
JMP NEAR LIST
JMP NEAR PUNCH
JMP NEAR READER
JMP NEAR HOME
JMP NEAR SELDSK
JMP NEAR SETTRK
JMP NEAR SETSEC
JMP NEAR SETDMA
JMP NEAR READ
JMP NEAR WRITE
JMP NEAR LISTST
JMP NEAR SECTRAN
BOOT:
STC
RET
WBOOT:
STC
RET
; CHAR I/O
CONST:
MOV AH, 1
INT 0x16
JZ .END
MOV AL, 0xFF
RET
.END:
XOR AL, AL
RET
CONIN:
XOR AX, AX
INT 0x16
TEST AL, AL
JZ CONIN
RET
CONOUT:
PUSH AX
PUSH BX
MOV AH, 0x0E
MOV AL, DL
XOR BX, BX
INT 0x10
POP BX
POP AX
RET
LIST:
PUSH DX
XOR AH, AH
MOV AL, DL
INT 0x17
POP DX
RET
LISTST:
STC
RET
PUNCH:
STC
RET
READER:
STC
RET
; DISK I/O
HOME:
RET
SELDSK:
MOV BYTE [DISKDL], CL
XOR BX, BX
RET
SETTRK:
PUSH CX
PUSH DX
MOV DX, CX
; CH for headnum, CL for SAL
MOV CX, 0x0006
; Take off LSB as head number
XOR CH, CH
RCR DX, 1
RCL CH, 1
MOV BYTE [DISKDH], CH
; DX is sector number now
; Shift into format for int13
; DX ------9876543210
SAL DX, CL
; DX 9876543210------
ROL DX, 1
ROL DX, 1
; DX 76543210------98
SAL DL, CL
; DX 7654321098------
AND WORD [DISKCX], 0x003F
OR WORD [DISKCX], DX
POP DX
POP CX
RET
SETSEC:
STC
RET
SETDMA:
MOV WORD [DISKBX], CX
RET
READ:
STC
RET
WRITE:
STC
RET
SECTRAN:
STC
RET