bios8086: implement CHS disk i/o using int13h

This commit is contained in:
Nero 2019-10-25 13:09:53 +00:00
parent a016fb0981
commit ad8a347d7d
2 changed files with 91 additions and 12 deletions

View File

@ -1,4 +1,5 @@
FLOPPY = 360
BIOS = 0xFA00
PROGRAMS = $(patsubst %.asm,%.com,$(wildcard com/*.asm))
DISTFILES = rdos.bin $(PROGRAMS)
@ -10,6 +11,7 @@ QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
NASM = nasm
NASM_ARGS = -s -Ilib -Plib/nasmcomp.asm -w-macro-params
NASM_ARGS += -DBIOS=$(BIOS)
EMUL = utils/emul
@ -46,6 +48,9 @@ rom/%.rom: rom/%.asm
com/%.com: com/%.asm
$(NASM) $(NASM_ARGS) -o $@ $<
bios%.bin: bios/%.asm
$(NASM) $(NASM_ARGS) -o $@ $<
fdimage.img: boot/fat.bs $(DISTFILES)
mformat -C -i $@ -f $(FLOPPY) -B boot/fat.bs ::
mcopy -i $@ $(DISTFILES) ::

View File

@ -1,9 +1,8 @@
ORG (RAM-0x600)
ORG BIOS
CPU 8086
DISKCX: EQU 0x40
DISKDL: EQU 0x42
DISKDH: EQU 0x43
DISKDX: EQU 0x42
DISKBX: EQU 0x44
JMP NEAR BOOT
@ -22,10 +21,11 @@ JMP NEAR SETDMA
JMP NEAR READ
JMP NEAR WRITE
JMP NEAR LISTST
JMP NEAR SECTRAN
BOOT:
STC
MOV AL, 0x19
CALL MSG
DB "BIOS 8086", 0
RET
WBOOT:
@ -50,6 +50,44 @@ CONIN:
JZ CONIN
RET
MSG:
POP SI
.LOOP:
MOV DL, BYTE [SI]
INC SI
TEST DL, DL
JZ .END
CALL CONOUT
JMP .LOOP
.END:
MOV DL, 0x20
CALL CONOUT
CALL PRINTAL
MOV DL, 0x0A
CALL CONOUT
MOV DL, 0x0D
CALL CONOUT
PUSH SI
RET
PRINTAL:
PUSH AX
PUSH DX
AAM 16
MOV DL, AH
CALL PRINTNIB
MOV DL, AL
CALL PRINTNIB
POP DX
POP AX
RET
PRINTNIB:
ADD DL, 0x30
CMP DL, 0x3a
JL CONOUT
ADD DL, 0x07
CONOUT:
PUSH AX
PUSH BX
@ -86,7 +124,7 @@ HOME:
RET
SELDSK:
MOV BYTE [DISKDL], CL
MOV BYTE [DISKDX], CL
XOR BX, BX
RET
@ -102,7 +140,7 @@ SETTRK:
XOR CH, CH
RCR DX, 1
RCL CH, 1
MOV BYTE [DISKDH], CH
MOV BYTE [DISKDX+1], CH
; DX is sector number now
; Shift into format for int13
@ -122,7 +160,8 @@ SETTRK:
RET
SETSEC:
STC
AND WORD [DISKCX], 0xFFA0
OR BYTE [DISKCX], CL
RET
SETDMA:
@ -130,13 +169,48 @@ SETDMA:
RET
READ:
STC
PUSH CX
PUSH DX
PUSH BX
MOV AX, 0x0201
MOV CX, [DISKCX]
MOV DX, [DISKDX]
MOV BX, [DISKBX]
INT 0x13
XCHG AH, AL
POP BX
POP DX
POP CX
JC DISKERR
RET
WRITE:
STC
PUSH CX
PUSH DX
PUSH BX
MOV AX, 0x0301
MOV CX, [DISKCX]
MOV DX, [DISKDX]
MOV BX, [DISKBX]
INT 0x13
XCHG AH, AL
POP BX
POP DX
POP CX
JC DISKERR
RET
SECTRAN:
STC
DISKERR:
PUSHF
PUSH SI
CALL MSG
DB "DISKERR", 0
POP SI
POPF
RET