Separate out headers for structures
This commit is contained in:
parent
a49e3b2610
commit
b164c79f42
2
Makefile
2
Makefile
@ -50,7 +50,7 @@ com/%.com: com/%.asm
|
|||||||
$(NASM) $(NASM_ARGS) -o $@ $<
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
||||||
|
|
||||||
bdos/%.bin: bdos/%.asm lib/*.asm
|
bdos/%.bin: bdos/%.asm lib/*.asm
|
||||||
$(NASM) $(NASM_ARGS) -o $@ -I bdos $<
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
||||||
|
|
||||||
bios/%.bin: bios/%.asm
|
bios/%.bin: bios/%.asm
|
||||||
$(NASM) $(NASM_ARGS) -o $@ $<
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
ORG BDOS
|
ORG BDOS
|
||||||
|
|
||||||
%include "bios/header.asm"
|
%include "hdr/bios.asm"
|
||||||
|
%include "hdr/fcb.asm"
|
||||||
|
%include "hdr/bpb.asm"
|
||||||
|
|
||||||
DISKBUF: EQU (BDOS-0x200) ; deblocking
|
DISKBUF: EQU (BDOS-0x200) ; deblocking
|
||||||
STACK: EQU (DISKBUF) ; grows down
|
DISKBPB: EQU (DISKBUF-21) ; BPB of the current driv
|
||||||
DEFDRV: EQU 4
|
DISKDRV: EQU (DISKBPB-1) ; BYTE denoting drive of current fcb
|
||||||
|
STACK: EQU (DISKDRV & 0xFFFE) ; even address, grows down
|
||||||
|
|
||||||
FCB_DRV: EQU 0 ; BYTE 0=A: 1=B: 2=C: ...
|
DEFDRV: EQU 4 ; default drive when opening a FCB
|
||||||
FCB_NAM: EQU 1 ; 8 BYTES, space padded
|
|
||||||
FCB_EXT: EQU 9 ; 3 BYTES, space padded
|
|
||||||
FCB_TYP: EQU 12 ; 1 for regular file
|
|
||||||
FCB_BLK: EQU 13 ; current 128b block in sector
|
|
||||||
FCB_CLU: EQU 14 ; current sector
|
|
||||||
FCB_LFT: EQU 16 ; bytes left to read in current file
|
|
||||||
|
|
||||||
SYSCALL:
|
SYSCALL:
|
||||||
TEST CL, CL
|
TEST CL, CL
|
||||||
@ -25,8 +22,9 @@ SYSCALL:
|
|||||||
JE PUTS
|
JE PUTS
|
||||||
CMP CL, 10
|
CMP CL, 10
|
||||||
JE GETS
|
JE GETS
|
||||||
STC
|
CMP CL, 11
|
||||||
RET
|
JE STATUS
|
||||||
|
JMP SYSCALL2
|
||||||
|
|
||||||
SETUP:
|
SETUP:
|
||||||
MOV SP, STACK
|
MOV SP, STACK
|
||||||
@ -34,16 +32,10 @@ SETUP:
|
|||||||
MOV CX, DISKBUF
|
MOV CX, DISKBUF
|
||||||
CALL SETDMA
|
CALL SETDMA
|
||||||
|
|
||||||
MOV DL, BYTE [DEFDRV]
|
MOV CL, 0x00
|
||||||
ADD DL, '@'
|
CALL LOADBPB
|
||||||
CALL PUTC
|
|
||||||
MOV DL, '>'
|
|
||||||
CALL PUTC
|
|
||||||
|
|
||||||
MOV DX, 0x7F
|
MOV AX, [DISKBPB]
|
||||||
MOV BYTE [0x7F], 0x2F
|
|
||||||
MOV BYTE [0x80], 2
|
|
||||||
CALL GETS
|
|
||||||
|
|
||||||
INT3
|
INT3
|
||||||
|
|
||||||
@ -63,8 +55,7 @@ GETC:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
PUTC:
|
PUTC:
|
||||||
CALL CONOUT
|
JMP CONOUT
|
||||||
RET
|
|
||||||
|
|
||||||
PUTS:
|
PUTS:
|
||||||
PUSH SI
|
PUSH SI
|
||||||
@ -134,3 +125,53 @@ GETS_BS:
|
|||||||
CALL PUTC
|
CALL PUTC
|
||||||
DEC CL
|
DEC CL
|
||||||
JMP GETS_L
|
JMP GETS_L
|
||||||
|
|
||||||
|
STATUS:
|
||||||
|
JMP CONST
|
||||||
|
|
||||||
|
SYSCALL2:
|
||||||
|
CMP CL, 13
|
||||||
|
JE DISKRST
|
||||||
|
CMP CL, 14
|
||||||
|
JE SETDEFDSK
|
||||||
|
CMP CL, 15
|
||||||
|
RET
|
||||||
|
|
||||||
|
DISKRST:
|
||||||
|
MOV BYTE [DISKDRV], 0xFF
|
||||||
|
RET
|
||||||
|
|
||||||
|
SETDEFDSK:
|
||||||
|
MOV BYTE [DEFDRV], DL
|
||||||
|
RET
|
||||||
|
|
||||||
|
; IN CL drive num
|
||||||
|
LOADBPB:
|
||||||
|
PUSH CX
|
||||||
|
CALL SELDSK
|
||||||
|
; first track
|
||||||
|
MOV CX, 0
|
||||||
|
CALL SETTRK
|
||||||
|
; first sector
|
||||||
|
MOV CX, 1
|
||||||
|
CALL SETSEC
|
||||||
|
; into default diskbuf
|
||||||
|
MOV CX, DISKBUF
|
||||||
|
CALL SETDMA
|
||||||
|
CALL READ
|
||||||
|
; copy BPB
|
||||||
|
PUSH SI
|
||||||
|
PUSH DI
|
||||||
|
MOV CX, 21
|
||||||
|
MOV SI, DISKBUF+0x0B
|
||||||
|
MOV DI, DISKBPB
|
||||||
|
REP MOVSB
|
||||||
|
POP DI
|
||||||
|
POP SI
|
||||||
|
; store drive number
|
||||||
|
POP CX
|
||||||
|
MOV BYTE [DISKDRV], CL
|
||||||
|
RET
|
||||||
|
|
||||||
|
FCBOPEN:
|
||||||
|
RET
|
||||||
|
12
hdr/bpb.asm
Normal file
12
hdr/bpb.asm
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
; BPB from first sector on FAT fs, starting 0x0B
|
||||||
|
BPB_SS: EQU 0 ; WORD sector size
|
||||||
|
BPB_SC: EQU 2 ; BYTE sectors per cluster
|
||||||
|
BPB_RSC: EQU 3 ; WORD reserved sector count
|
||||||
|
BPB_FN: EQU 5 ; BYTE number of FATs
|
||||||
|
BPB_RDE: EQU 6 ; WORD number of root directory entries
|
||||||
|
BPB_TS: EQU 8 ; WORD total number of sectors
|
||||||
|
BPB_MI: EQU 10 ; BYTE medium identifier
|
||||||
|
BPB_SF: EQU 11 ; WORD sectors per FAT
|
||||||
|
BPB_SPT: EQU 13 ; WORD sectors per track
|
||||||
|
BPB_NOS: EQU 15 ; WORD number of sides/heads
|
||||||
|
BPB_PO: EQU 17 ; DWORD partition offset
|
10
hdr/fcb.asm
Normal file
10
hdr/fcb.asm
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
; File control block
|
||||||
|
FCB_DRV: EQU 0 ; BYTE 0=A: 1=B: 2=C: ...
|
||||||
|
FCB_NAM: EQU 1 ; 8 BYTES, space padded
|
||||||
|
FCB_EXT: EQU 9 ; 3 BYTES, space padded
|
||||||
|
FCB_TYP: EQU 12 ; BYTE FCB type
|
||||||
|
; TYP=1: regular file
|
||||||
|
FCB_BLK: EQU 13 ; current 128b block in sector
|
||||||
|
FCB_CLU: EQU 14 ; current sector
|
||||||
|
FCB_LFT: EQU 16 ; bytes left to read in current file
|
||||||
|
FCB_END: EQU 20 ; FCB length
|
Loading…
Reference in New Issue
Block a user