From a016fb0981918bef8fd36cff09738a8521149eda Mon Sep 17 00:00:00 2001 From: Nero <41307858+nero@users.noreply.github.com> Date: Thu, 24 Oct 2019 23:11:19 +0000 Subject: [PATCH] PoC CBIOS --- bios/8086.asm | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 bios/8086.asm diff --git a/bios/8086.asm b/bios/8086.asm new file mode 100644 index 0000000..c939e49 --- /dev/null +++ b/bios/8086.asm @@ -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