2012.6.18
前へ
次へ
ホームページトップへ戻る

復活!CP/M ワンボードマイコンでCP/Mを!
CP/MがTK−80互換のワンボードマイコンの上で復活します
ND80ZVとMYCPU80の上でCP/Mが走ります

[第154回]


●CP/M互換DOS(仮RAMディスク版)ZBDOSプログラムのソースリスト

今回は前回に続いて、出来あがりましたCP/M互換DOS(仮RAMディスク版)ZBDOSプログラムのソースリストをお見せします。

;bdos for nd80z3
;CP/M2.2 compatible
;2012/5/6 5/7 5/8 5/9 5/11 5/12 5/13 5/14 5/15 5/16
;5/17 5/19 5/20 5/21 5/22 5/23 5/25 5/28 5/29 5/31
;6/1 6/2 6/7 6/8
;
        ORG $C406
;
        B_BOOT=$D200
        B_WBOOT=$D203
        B_CONST=$D206
        B_CONIN=$D209
        B_CONOUT=$D20C
        B_LIST=$D20F
        B_PUNCH=$D212
        B_READER=$D215
        B_HOME=$D218
        B_SELDSK=$D21B
        B_SETTRK=$D21E
        B_SETSEC=$D221
        B_SETDMA=$D224
        B_READ=$D227
        B_WRITE=$D22A
        B_PRSTAT=$D22D
        SECTRN=$D230
        ZREENT=$D236
;
        IOBYTE=$8003
;
        CURDRVVCT=$D000
        ROVCT=$D002
        CURDRV=$D004
        CDRV_DIRWK=$D005
        DMABFADRS=$D006
        DIRTRK=$D008
        DIRSCT=$D009
        FNPOS=$D00A;in DIR all
        FNPOSS=$D00B;in SECTOR
        SAVECNTR=$D00C;-D00D
        DIRCNTR=$D00E
        DRVCHR=$D00F
;
        DPARAM=$D010;to $D02E
        DIRADRS=$D018
        DPTOP=$D01A
        CSVTOP=$D01C
        ALVTOP=$D01E
        SEC=$D020;SECTORS PER TRACK/DISK PARAMETER TOP
        BLKSFT=$D022
        BLKMSK=$D023
;
        BLKMAX=$D025
        DIRMAX=$D027
        DIRALC=$D029
        ;
        SYSFCB=$D03C
        SYSFCBEX=$D048
        SYSFCBRC=$D04B
        SYSFCBALC=$D04C;=SYSFCB2
        SYSFCBCR=$D05C
        ;D05D-D05F reserved
        INDATA=$D060
        CURROMK=$D061
        DIRBFADRS=$D062
        CURSOR=$D064;-D065;D065 is dummy
        CONBFINWK=$D066;-D067
        CURSORWK=$D068
        RWSW=$D069
;
        CONINBF=$D0FE;-D1FE
;               
;BDOS ENTRY
;
        JP BDOS
;jump table
        JP SYSRES;00
        JP CONIN;01
        JP CONOUT;02
        JP RDRIN;03
        JP PUNOUT;04
        JP LSTOUT;05
        JP CONINOT;06
        JP IOBYTERD;07
        JP IOBYTESET;08
        JP DEOUT;09
        JP CONBFIN;0A
        JP CONCHK;0B
        JP VERRD;0C
        JP DISKRES;0D
        JP DRVNOSET;0E
        JP OPEN;0F
        JP CLOSE;10
        JP SRCHFST;11
        JP SRCHNXT;12
        JP DELETE;13
        JP SEQRD;14
        JP SEQWR;15
        JP NEWOPEN;16
        JP RENAME;17
        JP CURDRVVCTRD;18
        JP CURDRVNORD;19
        JP DMAADRSSET;1A
        JP ALVADRSRD;1B
        JP WPSET;1C
        JP ROVRD;1D
        JP ATTRSET;1E
        JP DPARAMRD;1F
        JP RNDMRD;21
        JP RNDMWR;22
        JP FSIZERD;23
        JP RNDMNOSET;24
        JP DRVVCTRES;25
        JP RNDMWR0;28
;
        JP ALVSET
;
BDOS:LD L,C
        LD H,00
        ADD HL,HL
        LD BC,FNCTBL
        ADD HL,BC
        LD A,(HL)
        INC HL
        LD H,(HL)
        LD L,A
        JP (HL)
;
FNCTBL:DW SYSRES;00
        DW CONIN;01
        DW CONOUT;02
        DW RDRIN;03
        DW PUNOUT;04
        DW LSTOUT;05
        DW CONINOT;06
        DW IOBYTERD;07
        DW IOBYTESET;08
        DW DEOUT;09
        DW CONBFIN;0A
        DW CONCHK;0B
        DW VERRD;0C
        DW DISKRES;0D
        DW DRVNOSET;0E
        DW OPEN;0F
        DW CLOSE;10
        DW SRCHFST;11
        DW SRCHNXT;12
        DW DELETE;13
        DW SEQRD;14
        DW SEQWR;15
        DW NEWOPEN;16
        DW RENAME;17
        DW CURDRVVCTRD;18
        DW CURDRVNORD;19
        DW DMAADRSSET;1A
        DW ALVADRSRD;1B
        DW WPSET;1C
        DW ROVRD;1D
        DW ATTRSET;1E
        DW DPARAMRD;1F
        DW UNDEFINE;20
        DW RNDMRD;21
        DW RNDMWR;22
        DW FSIZERD;23
        DW RNDMNOSET;24
        DW DRVVCTRES;25
        DW UNDEFINE;26
        DW UNDEFINE;27
        DW RNDMWR0;28
;
;SYSTEM RESET FCALL 00
;
SYSRES:RET
;
;CONSOLE INPUT FCALL 01
;
CONIN:CALL CONINSB
        PUSH DE
        PUSH AF
        LD E,A
        CALL CONOUT
        POP AF
        POP DE
        RET
;
CONINSB:PUSH HL
        LD HL,INDATA
        LD A,(HL)
        OR A
        LD (HL),00
        POP HL
        RET NZ
        JP B_CONIN
;
;CONSOLE OUTPUT FCALL 02
;
CONOUT:PUSH HL
        PUSH BC
        LD HL,(CURSOR)
        LD A,E
        CP 08;BS
        JP Z,CONOUT2
        CP 09;TAB
        JP Z,CONOUT3
        CP 0D;CR
        JP Z,CONOUT4
        CP 0A;LF
        JP Z,CONOUT4
        CP 1B
        JP C,CONOUT44;ctrl+
CONOUT12:LD C,E
        CALL B_CONOUT
        INC L
        LD A,L
        CP 50
        JP Z,CONOUT42
        JP CONOUT43
;BS
CONOUT2:LD A,L
        OR A
        JP Z,CONOUT44
        LD C,E;BS
        CALL B_CONOUT
        DEC L
        LD A,L
        JP CONOUT43
;TAB
CONOUT3:CALL TABOUT
        JP CONOUT43
;
TABOUT:LD A,L
        CPL
        AND 07
        INC A
        LD B,A
        LD C,20
TABOUT1:CALL B_CONOUT
        INC L
        DEC B
        JP NZ,TABOUT1
        LD A,L
        CP 50
        RET NZ
        XOR A
        RET
;
;CR,LF
CONOUT4:LD C,E
        CALL B_CONOUT
CONOUT42:LD A,00
CONOUT43:LD (CURSOR),A
CONOUT44:CALL CONCHK
        POP BC
        POP HL
        RET
;
;READER INPUT FCALL 03
;
RDRIN:JP B_READER
;
;PUNCHER OUTPUT FCALL 04
;
PUNOUT:LD C,E
        JP B_PUNCH
;
;PRINTER OUTPUT FCALL 05
;
LSTOUT:RET
;
;CONSOLE INPUT/OUTPUT FCALL 06
;
CONINOT:LD A,E
        INC A;if FF
        JP Z,CONIO_IN
        LD C,E
        JP B_CONOUT
CONIO_IN:CALL B_CONST
        RET Z
        JP B_CONIN
;
;IOBYTE READ FCALL 07
;
IOBYTERD:LD A,(IOBYTE)
        RET
;
;IOBYTE SET FCALL 08
;
IOBYTESET:LD A,E
        LD (IOBYTE),A
        RET
;
;CHARACTER OUT FROM (DE) TO $ / FCALL 09
;
DEOUT:LD H,D
        LD L,E
DEOUT2:LD A,(HL)
        CP 24;$
        RET Z
        LD E,A
        CALL CONOUT
        INC HL
        JP DEOUT2
;
;CONSOLE BUFFER INPUT FCALL 0A
;if ctrl+D then BREAK
;
CONBFIN:LD HL,(CURSOR)
        LD A,L
        LD (CURSORWK),A
        LD H,D
        LD L,E
CONBFIN1:PUSH HL
        LD C,(HL)
        LD B,00
        INC HL
        PUSH HL
        INC HL
        LD (CONBFINWK),HL
CONBFIN2:CALL CONINSB
        AND 7F
        CP 04;ctrl+D
        JP NZ,CONBFIN22
        LD E,A
        LD A,B
        OR A
        JP Z,ZREENT
        LD A,E
CONBFIN22:CP 0D;CR
        JP Z,CONBFIN4
        CP 0A;LF
        JP Z,CONBFIN4
        CP 09;TAB
        JP Z,CONBFIN3
        CP 08;BS
        JP Z,CONBFIN5
        CP 12;^R
        JP Z,CONBFIN6
        CP 15;^U
        JP Z,CONBFIN7
        CP 18;^X
        JP Z,CONBFIN8
        CP 1B
        JP C,CONBFIN9
CONBFIN23:LD (HL),A
        LD E,A
        CALL CONOUT
CONBFIN24:INC HL
        INC B
        DEC C
        JP NZ,CONBFIN2
;CR,LF
CONBFIN4:POP HL
        LD (HL),B
        LD D,H
        LD E,L
        EX DE,HL
        LD A,B
        OR A
        JP Z,CONBFIN43
CONBFIN41:INC HL
        LD A,(HL)
        OR A
        JP P,CONBFIN42
        LD (HL),09;TAB
CONBFIN42:DEC B
        JP NZ,CONBFIN41
CONBFIN43:EX DE,HL
        POP DE;dummy
        RET
;
;TAB
CONBFIN3:PUSH HL
        PUSH BC
        LD HL,(CURSOR)
        LD A,L
        CPL
        AND 07
        LD B,A
        INC A
        LD C,A
        LD E,20
CONINBF31:CALL CONOUT
        DEC C
        JP NZ,CONINBF31
        LD A,B
        RLCA
        RLCA
        RLCA
        RLCA
        OR 89;TAB
        POP BC
        POP HL
        LD (HL),A
        JP CONBFIN24
;
;BS
CONBFIN5:LD A,B
        OR A
        JP Z,CONBFIN2
        DEC HL
        LD A,(HL)
        OR A
        JP M,CONBFIN54;TAB
        CP 20;ctrl check
        JP NC,CONBFIN52
        CALL BSOUT
CONBFIN52:CALL BSOUT
CONBFIN53:DEC B
        INC C
        JP CONBFIN2
CONBFIN54:PUSH HL
        PUSH BC
        RRCA
        RRCA
        RRCA
        RRCA
        AND 07
        INC A
        LD C,A
CONBFIN55:CALL BSOUT
        DEC C
        JP NZ,CONBFIN55
        POP BC
        POP HL
        JP CONBFIN53
;
BSOUT:CALL BSOUT2
        LD E,20
        CALL CONOUT
BSOUT2:LD E,08
        JP CONOUT
;
; ctrl+R
CONBFIN6:LD E,23;#
        CALL CONOUT
        PUSH BC
        LD A,(CURSORWK)
        LD C,A
        CALL CRLF
        LD A,C
        OR A
        JP Z,CONBFIN62
        LD E,20
CONBFIN61:CALL CONOUT
        DEC C
        JP NZ,CONBFIN61
CONBFIN62:LD HL,(CONBFINWK)
CONBFIN63:LD A,(HL)
        OR A
        JP M,CONBFIN66;TAB
        CP 20;ctrl check
        JP NC,CONBFIN64
        CALL CTRLDSP
        JP CONBFIN65
CONBFIN64:LD E,A
        CALL CONOUT
CONBFIN65:INC HL
        DEC B
        JP NZ,CONBFIN63
        POP BC
        JP CONBFIN2
CONBFIN66:PUSH HL
        PUSH BC
        LD HL,(CURSOR)
        CALL TABOUT
        LD (CURSOR),HL
        POP BC
        POP HL
        JP CONBFIN65
;
CRLF:LD E,0D
        CALL CONOUT
        LD E,0A
        JP CONOUT
;
;ctrl+U
CONBFIN7:LD E,23;#
        CALL CONOUT
        LD A,(CURSORWK)
        LD C,A
        CALL CRLF
        LD A,C
        OR A
        JP Z,CONBFIN72
CONBFIN71:LD E,20
        CALL CONOUT
        DEC C
        JP NZ,CONBFIN71
CONBFIN72:POP HL
        POP HL
        JP CONBFIN1
;
;ctrl+X
CONBFIN8:DEC HL
        LD A,(HL)
        CP 20;ctrl check
        JP NC,CONBFIN82
        CALL BSOUT
CONBFIN82:CALL BSOUT
        DEC B
        JP NZ,CONBFIN8
        POP HL
        POP HL
        JP CONBFIN1
;
;ctrl+
CONBFIN9:CALL CTRLDSP
        JP CONBFIN23
CTRLDSP:PUSH AF
        LD E,5E;^
        CALL CONOUT
        POP AF
        PUSH AF
        ADD A,40
        LD E,A
        CALL CONOUT
        POP AF
        RET
;
;CONSOLE STATUS CHECK FCALL 0B
;
CONCHK:PUSH HL
        LD HL,INDATA
        LD A,(HL)
        OR A
        JP NZ,CONCHK3
        CALL B_CONST
        JP NZ,CONCHK1
        POP HL
        RET
CONCHK1:CALL B_CONIN
        CP 13;Ctrl+S
        JP NZ,CONCHK2
        CALL B_CONIN
        CP 04;Ctrl+D
        JP NZ,CONCHK2
        JP ZREENT
CONCHK2:LD (HL),A
CONCHK3:LD A,01
        POP HL
        RET
;
;VERSION NO. READ FCALL 0C
;
VERRD:LD HL,$0022
        RET
;
;DISK RESET FCALL 0D
;
DISKRES:LD HL,$0000
        LD (ROVCT),HL
        RET
;
;DISK DRIVE NO. SET FCALL 0E
;
DRVNOSET:LD A,E
DRVNOSET1:LD C,A
        LD B,A
        PUSH BC
        CALL B_SELDSK
        JP NZ,DRVNOSETE
        LD DE,DPARAM
        LD C,10
        CALL PRMCOPY
        LD HL,(DPTOP)
        LD C,0F
        CALL PRMCOPY
        POP BC
        LD HL,$0001
        INC C
DRVNOSET2:DEC C
        JP Z,DRVNOSET3
        ADD HL,HL
        JP DRVNOSET2
DRVNOSET3:LD D,H
        LD E,L
        LD A,L
        LD HL,(CURDRVVCT)
        OR L
        LD L,A
        LD A,D
        OR H
        LD H,A
        LD (CURDRVVCT),HL
        LD A,B
        LD (CURDRV),A
        LD A,E
        LD HL,(ROVCT)
        AND L
        LD L,A
        LD A,D
        AND H
        OR L
        LD (CURROMK),A
        RET Z
        LD A,FF
        LD (CURROMK),A
        XOR A
        RET
        DRVNOSETE:POP BC
        RET
;
PRMCOPY:LD A,(HL)
        LD (DE),A
        INC HL
        INC DE
        DEC C
        JP NZ,PRMCOPY
        RET
;
;DISK FILE OPEN FCALL 0F
;
OPEN:CALL SRCHFST
        CP FF
        RET Z
        PUSH HL
        LD BC,$000C
        ADD HL,BC
        LD A,(HL);extent No.
        POP HL
        OR A
        JP Z,OPEN2
        CALL SRCHNXT
        CP FF
        RET Z
        PUSH HL
        LD BC,$000C
        ADD HL,BC
        LD A,(HL);extent No.
        POP HL
        OR A
        JP Z,OPEN2
        LD A,FF
        RET
OPEN2:LD B,20
        LD A,(DE)
        PUSH AF
        PUSH DE
OPEN3:LD A,(HL)
        LD (DE),A
        INC DE
        INC HL
        DEC B
        JP NZ,OPEN3
        POP DE
        POP AF
        LD (DE),A
        LD A,(FNPOSS)
        RET
;
;DISK FILE CLOSE FCALL 10
;
CLOSE:CALL SRCHFST
        CP FF
        RET Z
CLOSE1:PUSH HL
        LD BC,$000C
        ADD HL,BC
        LD A,(HL);extent No.
        LD H,D
        LD L,E
        ADD HL,BC
        LD B,(HL)
        POP HL
        CP B
        JP Z,CLOSE2
        CALL SRCHNXT
        CP FF
        RET Z
        JP CLOSE1
CLOSE2:LD B,20
        PUSH DE
        PUSH HL
CLOSE3:LD A,(DE)
        LD (HL),A
        INC HL
        INC DE
        DEC B
        JP NZ,CLOSE3
        POP HL
        LD (HL),00
        CALL B_WRITE
        POP DE
        LD A,(FNPOSS)
        RET
;
;FILE NAME SEARCH FIRST FCALL 11  return with HL=FCB
;
SRCHFST:CALL CURDRVCK
        CALL DIRSET
SRCHFST3:LD HL,(DIRBFADRS)
        LD BC,$0400
SRCHFST4:PUSH BC
        CALL NMCMP
        JP Z,SRCHFST8
SRCHFST42:LD BC,$0020
        ADD HL,BC
        POP BC
        INC C
        DEC B
        JP NZ,SRCHFST4
SRCHFST43:LD HL,FNPOS
        INC (HL)
        INC (HL)
        INC (HL)
        INC (HL)
        LD A,(DIRMAX)
        CP (HL)
        JP C,SRCHFST9
        CALL NDIRSET
        JP SRCHFST3
;
SRCHFST8:POP BC
        LD A,C
        LD (FNPOSS),A
        RET
SRCHFST9:LD A,FF
        RET
;
;NAME COMP return with HL=FCB
NMCMP:LD A,(HL)
        CP E5
        JP NZ,NMCMP02
        OR A;reset zflag
        RET
NMCMP02:PUSH DE
        PUSH HL
        INC DE
        INC HL
        LD C,08
NMCMP1:LD A,(DE)
        CP 3F;?
        JP Z,NMCMP2
        CP (HL)
        JP Z,NMCMP2
        POP HL
        POP DE
        RET
NMCMP2:INC DE
        INC HL
        DEC C
        JP NZ,NMCMP1
        LD C,03
NMCMP3:LD A,(DE)
        AND 7F
        CP 3F;?
        JP Z,NMCMP4
        LD B,A
        LD A,(HL)
        AND 7F
        CP B
        JP Z,NMCMP4
        POP HL
        POP DE
        RET
NMCMP4:INC DE
        INC HL
        DEC C
        JP NZ,NMCMP3
        POP HL
        POP DE
        RET
;
;FILE NAME SEARCH NEXT FCALL 12
;
SRCHNXT:LD A,(FNPOSS)
        CP 03
        JP Z,SRCHFST43
        LD C,A
        LD A,04
        SUB C
        LD B,A
        LD A,C
        LD HL,(DIRBFADRS)
        OR A
        JP Z,SRCHNXT22
        PUSH DE
        LD DE,$0020
SRCHNXT2:ADD HL,DE
        DEC A
        JP NZ,SRCHNXT2
        POP DE
SRCHNXT22:PUSH BC
        JP SRCHFST42
;
;FILE DELETE FCALL 13
;
DELETE:LD A,(CURROMK)
        OR A
        RET NZ
        CALL SRCHFST
        CP FF
        RET Z
DELETE2:LD (HL),E5
        PUSH DE
        LD DE,$0020
        ADD HL,DE
        LD B,10;=16
DELETE3:LD A,(HL)
        OR A
        JP Z,DELETE4
        PUSH BC
        LD B,7F
        CALL BLKTOALV
        POP BC
DELETE4:DEC B
        JP NZ,DELETE3
        EX DE,HL
        LD HL,(DIRBFADRS)
        EX DE,HL
        CALL B_WRITE
        POP DE
        CALL SRCHNXT
        CP FF
        JP NZ,DELETE2
        XOR A
        RET
;
;SEQUENTIAL READ FCALL 14
;
SEQRD:LD HL,$000F
        ADD HL,DE
        LD B,(HL);rec no. in this extent
        PUSH HL
        LD DE,$0011
        ADD HL,DE
        LD A,(HL);next rec no.
        CP B
        JP Z,SEQRDEND; end or next extent!!
        INC (HL)
        POP HL
        INC HL
        CALL SRCHBLK
SEQRD1:PUSH AF;position
        LD C,(HL)
        LD B,00
        CALL BLKTOTS;B=TRK,C=SEC
        POP AF
        ADD A,C
        LD C,A
        LD HL,SEC
        CP (HL)
        JP C,SEQRD2
        INC B
        SUB (HL)
        LD C,A
SEQRD2:PUSH BC
        LD C,B
        CALL B_SETTRK
        POP BC
        CALL B_SETSEC
        LD HL,(DMABFADRS)
        LD B,H
        LD C,L
        CALL B_SETDMA
        CALL B_READ
        XOR A
        RET
;
SEQRDEND:POP HL
        LD A,01;end of file
        RET     
;
;rec no. to brock no. alloc & position
;
SRCHBLK:PUSH AF
        LD A,(BLKMSK)
        INC A
        LD C,A
        POP AF
        CP C
        RET C
        INC HL
        SUB C
        JP SRCHBLK
;
;SEQUENTIAL WRITE FCALL 15
;
SEQWR:LD A,(CURROMK)
        OR A
        RET NZ
        LD HL,$000F
        ADD HL,DE
        LD A,(HL);rec amount in this extent
        INC A
        CP 81
        JP Z,SEQWR8;next extent
        LD (HL),A
        PUSH HL
        LD DE,$0011
        ADD HL,DE
        LD A,(HL)
        INC (HL);next rec no.
        POP HL
        INC HL
        CALL SRCHBLK
SEQWR1:PUSH AF;position
        LD A,(HL)
        OR A
        JP NZ,SEQWR2
        CALL SRCHNXTBLK;A=next block no.
        JP C,SEQWR9;DISK FULL
        LD (HL),A;next block no.
        PUSH BC
        LD B,80
        CALL BLKTOALV
        POP BC
SEQWR2:LD C,(HL)
        LD B,00
        CALL BLKTOTS;B=TRK,C=SEC
        POP AF
        ADD A,C
        LD C,A
        LD HL,SEC
        CP (HL)
        JP C,SEQWR3
        INC B
        SUB (HL)
        LD C,A
SEQWR3:PUSH BC
        LD C,B
        CALL B_SETTRK
        POP BC
        CALL B_SETSEC
        LD HL,(DMABFADRS)
        LD B,H
        LD C,L
        CALL B_SETDMA
        CALL B_WRITE
        XOR A
        RET
;
;next extent make !!!
SEQWR8:RET
;
SEQWR9:POP AF
        LD A,02;DISK FULL
        RET
;
;search next block return with A=next block no.
SRCHNXTBLK:PUSH HL
        PUSH DE
        PUSH BC
        LD HL,(ALVTOP)
        LD A,(BLKMAX);<FF !
        INC A
        LD B,A
        LD C,00
SRCHNXTBLK1:LD D,08
        LD A,(HL)
SRCHNXTBLK2:RLCA
        JP NC,SRCHNXTBLK3
        DEC B
        JP Z,SRCHNXTBLK9;disk full
        INC C
        DEC D
        JP NZ,SRCHNXTBLK2
        INC HL
        JP SRCHNXTBLK1
SRCHNXTBLK3:LD A,C
        POP BC
        POP DE
        POP HL
        OR A;reset Cflag
        RET
SRCHNXTBLK9:POP BC
        POP DE
        POP HL
        SCF;disk full
        RET
        ;
;NEW FILE OPEN FCALL 16
;
NEWOPEN:CALL CURDRVCK
        CALL DIRSET
        CALL SRCHE5
        CP FF
        RET Z;directory full
        PUSH AF
        LD A,(CURROMK)
        OR A
        JP Z,NEWOPEN1
        POP BC;dummy
        RET
NEWOPEN1:PUSH HL
        LD HL,$0010
        ADD HL,DE
        XOR A
        LD B,10
NEWOPEN2:LD (HL),A
        INC HL
        DEC B
        JP NZ,NEWOPEN2
        POP HL
        LD B,20
NEWOPEN3:LD A,(DE)
        LD (HL),A
        INC HL
        INC DE
        DEC B
        JP NZ,NEWOPEN3
        LD HL,(DIRBFADRS)
        EX DE,HL
        CALL B_WRITE
        POP AF
        RET
;
CURDRVCK:LD A,(DE)
        OR A
        RET Z
        DEC A
        LD HL,CURDRV
        CP (HL)
        RET Z
        PUSH DE
        CALL DRVNOSET1
        POP DE
        RET
;
;dir search 'E5'
SRCHE5:PUSH DE
SRCHE5_2:LD HL,(DIRBFADRS)
        LD DE,$0400
SRCHE5_3:LD A,(HL)
        CP E5
        JP Z,SRCHE5_8
        LD BC,$0020
        ADD HL,BC
        INC E
        DEC D
        JP NZ,SRCHE5_3
        LD HL,FNPOS
        INC (HL)
        INC (HL)
        INC (HL)
        INC (HL)
        LD A,(DIRMAX)
        CP (HL)
        JP C,SRCHE5_9
        CALL NDIRSET
        JP SRCHE5_2
;
SRCHE5_8:LD A,E
        POP DE
        RET
SRCHE5_9:POP DE
        LD A,FF
        RET
;
;RENAME FCALL 17
;
RENAME:LD A,(CURROMK)
        OR A
        RET NZ
        CALL SRCHFST
        CP FF
        RET Z
RENAME2:INC HL
        PUSH DE
        EX DE,HL
        LD BC,$0011
        ADD HL,BC
        LD B,0B;=11
RENAME3:LD A,(HL)
        LD (DE),A
        INC HL
        INC DE
        DEC B
        JP NZ,RENAME3
        CALL B_WRITE
        POP DE
        CALL SRCHNXT
        CP FF
        JP NZ,RENAME2
        XOR A
        RET
;
;CURRENT DRIVE VECTOR(LOGIN VECTOR) ADDRESS READ FCALL 18
;
CURDRVVCTRD:LD HL,(CURDRVVCT)
        RET
;
;CURRENT DRIVE NO. READ FCALL 19
;
CURDRVNORD:LD A,(CURDRV)
        RET
;
;DMA ADRRESS SET FCALL 1A
;
DMAADRSSET:LD H,D
        LD L,E
        LD (DMABFADRS),HL
        RET
;
;ALLOCATION VECTOR ADDRESS READ FCALL 1B
;
ALVADRSRD:LD HL,(ALVTOP)
        RET
;
;WRITE PROTECT SET FCALL 1C
;
WPSET:LD HL,(ROVCT)
        EX DE,HL
        LD A,(CURDRV)
        INC A
        LD HL,$0001
WPSET1:DEC A
        JP Z,WPSET2
        ADD HL,HL
        JP WPSET1
WPSET2:LD A,H
        OR D
        LD H,A
        LD A,L
        OR E
        LD L,A
        LD (ROVCT),HL
        RET
;
;READ ONLY VECTOR ADDRESS READ FCALL 1D
;
ROVRD:LD HL,(ROVCT)
        RET
;
;FILE ATTRIBUTE SET FCALL 1E
;
ATTRSET:CALL SRCHFST
        CP FF
        RET Z
        PUSH HL
        LD BC,$000C
        ADD HL,BC
        LD A,(HL);extent No.
        POP HL
        OR A
        JP Z,ATTRSET2
        CALL SRCHNXT
        CP FF
        RET Z
        PUSH HL
        LD BC,$000C
        ADD HL,BC
        LD A,(HL);extent No.
        POP HL
        OR A
        JP Z,ATTRSET2
        LD A,FF
        RET
ATTRSET2:LD BC,$0009
        ADD HL,BC
        EX DE,HL
        ADD HL,BC
        LD B,03
ATTRSET3:LD A,(HL)
        LD (DE),A
        INC HL
        INC DE
        DEC B
        JP NZ,ATTRSET3
        CALL B_WRITE
        LD A,(FNPOSS)
        RET
;
;DISK PARAMETER ADDRESS READ FCALL 1F
;
DPARAMRD:LD HL,(DPTOP)
        RET
;
;UNDEFINE FCALL 20,26,27
;
UNDEFINE:RET
;
;RANDOM READ FCALL 21
;
RNDMRD:XOR A
        LD (RWSW),A
        CALL RNDMSB
        JP NC,SEQRD1
        LD A,FF;********** err CODE
        RET
;
;rec no. to BLOCK aloc position
;return value B=this extent no. C=rec no. in this extent
;HL=BLOCK ALOC POINT
;if err then cf on
RNDMSB:LD HL,$0021
        ADD HL,DE
        LD A,(HL)
        INC HL
        LD H,(HL)
        LD L,A;HL=next rec no.
        LD B,07;
RNDMSB2:LD A,H
        RRA
        LD H,A
        LD A,L
        RRA
        LD L,A
        DEC B
        JP NZ,RNDMSB2
        LD A,H
        RRA
        RRA
        LD C,A;rec no. in extent
        LD B,L;extent no.
RNDMSB3:LD HL,$000C
        ADD HL,DE
        LD A,B
        CP (HL)
        JP NZ,RNDMSB5;read next extent
RNDMSB30:INC HL
        INC HL
        INC HL
        LD A,(RWSW)
        OR A
        JP Z,RNDMSB31
        LD A,C
        INC A
        CP (HL);amount in this extent
        JP C,RNDMSB31
        LD (HL),A
RNDMSB31:INC HL
        EX DE,HL
        LD HL,(BLKSFT)
        EX DE,HL;E=BLKSFT,D=BLKMSK
        LD A,C
        AND D
        LD D,A
        LD A,C
RNDMSB32:RRCA
        DEC E
        JP NZ,RNDMSB32
        AND 1F
        JP Z,RNDMSB42
RNDMSB4:INC HL
        DEC A
        JP NZ,RNDMSB4
RNDMSB42:LD A,D;position no. in block
        OR A;reset cf
        RET
;
RNDMSB5:PUSH BC
        PUSH AF
        LD A,(RWSW)
        OR A
        CALL NZ,CLOSE;save this FCB
        CALL SRCHFST
RNDMSB52:POP AF
        PUSH HL
        LD BC,$000C
        ADD HL,BC
        CP (HL);same extent No.?
        JP Z,RNDMSB6;FCB found
        POP HL
        PUSH AF
        CALL SRCHNXT
        CP FF
        JP Z,RNDMSB7;then,make new FCB
        JP RNDMSB52
;
RNDMSB6:POP HL
        PUSH DE
        LD B,20
RNDMSB62:LD A,(HL)
        LD (DE),A
        INC HL
        INC DE
        DEC B
        JP NZ,RNDMSB62
        POP DE
        LD HL,$000C
        ADD HL,DE
        POP BC
        LD (HL),B;extent No.
        JP RNDMSB30
;
RNDMSB7:POP AF
        LD A,(RWSW)
        OR A
        JP NZ,RNDMSB71
        POP BC
        SCF
        RET
RNDMSB71:POP BC
        LD HL,$000C
        ADD HL,DE
        LD (HL),B;extent No.
        PUSH HL
        INC HL
        LD B,13
        XOR A
RNDMSB72:LD (HL),A
        INC HL
        DEC B
        JP NZ,RNDMSB72
        PUSH BC
        CALL DIRSET
        CALL SRCHE5
        CP FF
        JP NZ,RNDMSB73
        POP BC
        POP HL
        SCF
        RET
RNDMSB73:PUSH DE
        LD B,20
RNDMSB74:LD A,(DE)
        LD (HL),A
        INC HL
        INC DE
        DEC B
        JP NZ,RNDMSB74
        LD HL,(DIRBFADRS)
        EX DE,HL
        CALL B_WRITE
        POP DE
        POP BC
        POP HL
        JP RNDMSB30
;
;RANDOM WRITE FCALL 22
;
RNDMWR:LD A,(CURROMK)
        OR A
        RET NZ
        LD A,01
        LD (RWSW),A
        CALL RNDMSB
        JP NC,SEQWR1
        LD A,FF;******* err CODE
        RET
;
;FILE SIZE READ FCALL 23
;
FSIZERD:LD B,00
        PUSH BC;B=max extent No.
        CALL SRCHFST
        CP FF
        JP Z,FSIZERDERR
FSIZERD1:LD BC,$000C
        ADD HL,BC
        LD A,(HL);extent No.
        POP BC;max extent No.
        CP B
        JP C,FSIZERD2
        LD B,A
        INC HL
        INC HL
        INC HL
        LD C,(HL);sectors in this extent
FSIZERD2:PUSH BC
        CALL SRCHNXT
        CP FF
        JP NZ,FSIZERD1
        POP BC
        LD L,B
        LD H,00
        LD B,07
FSIZERD3:ADD HL,HL
        DEC B
        JP NZ,FSIZERD3;*128
        ADD HL,BC
        EX DE,HL
        LD BC,$0021
        ADD HL,BC
        LD (HL),E
        INC HL
        LD (HL),D
        INC HL
        LD (HL),00;**************
        XOR A
        RET
FSIZERDERR:POP BC
        LD A,FF
        RET
;
;RANDOM ACCESS RECOAD NO. SET FCALL 24
;
RNDMNOSET:LD HL,$000C
        ADD HL,DE
        LD C,(HL);extent
        LD HL,$0020
        ADD HL,DE
        LD L,(HL);next rec no.
        LD A,(BLKSFT)
        LD B,00
        LD H,A
        OR A;reset CF
RNDMNOSET2:CALL RLBC
        DEC H
        JP NZ,RNDMNOSET2
        LD H,04
RNDMNOSET3:CALL RLBC
        DEC H
        JP NZ,RNDMNOSET3
        LD H,00
        ADD HL,BC
        LD B,H
        LD C,L
        LD HL,$0021
        ADD HL,DE
        LD (HL),C
        INC HL
        LD (HL),B
        INC HL
        LD (HL),00
        RET
;
RLBC:LD A,C
        RLA
        LD C,A
        LD A,B
        RLA
        LD B,A
        RET
;
;WITH DISK DRIVE VECTOR RESET FCALLO 25
;
DRVVCTRES:LD A,D
        LD B,D
        LD C,E
        LD HL,(CURDRVVCT)
        EX DE,HL
        LD HL,(ROVCT)
        CPL
        LD B,A
        AND H
        LD H,A
        LD A,B
        AND D
        LD D,A
        LD A,C
        CPL
        LD C,A
        AND L
        LD L,A
        LD A,C
        AND E
        LD E,A
        LD (ROVCT),HL
        EX DE,HL
        LD (CURDRVVCT),HL
        RET
;
;RANDOM WRITE WITH 00 FCALL 28
;
RNDMWR0:LD A,(CURROMK)
        OR A
        RET NZ
        CALL RNDMSB
        PUSH HL
        CALL SEQWR1
        POP HL
        CP FF
        RET Z
        LD A,(BLKMSK)
RNDMWR03:PUSH HL
        PUSH AF
        CALL SEQRD1
        CP FF
        JP Z,RNDMWR09
        LD HL,(DMABFADRS)
        LD B,80
        LD A,E5
RNDMWR04:CP (HL)
        JP NZ,RNDMWR06
        INC HL
        DEC B
        JP NZ,RNDMWR04
        LD B,80
        LD HL,(DMABFADRS)
        XOR A
RNDMWR05:LD (HL),A
        INC HL
        DEC B
        JP NZ,RNDMWR05
        POP AF
        POP HL
        PUSH HL
        PUSH AF
        CALL SEQWR1
        CP FF
        JP Z,RNDMWR09
RNDMWR06:POP AF
        POP HL
        DEC A
        JP P,RNDMWR03
        XOR A
        RET
;
RNDMWR09:POP AF
        POP HL
        LD A,FF
        RET
;
ALVSET:LD HL,(BLKMAX);clr ALV
        LD B,H
        LD A,L
        LD HL,(DIRALC)
        LD D,H
        LD E,L
        LD HL,(ALVTOP)
        LD (HL),E
        INC HL
        LD (HL),D
;
        CALL DIRSET
        LD C,00
ALVSET1:LD HL,(DIRBFADRS)
        LD B,04
ALVSET11:LD A,(HL)
        CP E5
        JP Z,ALVSET2
        LD DE,$0010
        ADD HL,DE
        LD D,10
ALVSET12:LD A,(HL)
        OR A
        JP Z,ALVSET13
        PUSH BC
        LD B,80
        CALL BLKTOALV
        POP BC
ALVSET13:INC HL
        DEC D
        JP NZ,ALVSET12
        JP ALVSET21
ALVSET2:LD DE,$0020
        ADD HL,DE
ALVSET21:INC C
        DEC B
        JP NZ,ALVSET11
        LD A,(DIRMAX)
        CP C
        RET C
        PUSH BC
        CALL NDIRSET
        POP BC
        JP ALVSET1
;
;A=BLOCK NO. B=80(SET) B=7F(CLR)
BLKTOALV:PUSH HL
        LD HL,(ALVTOP)
BLKTOALV1:CP 08
        JP C,BLKTOALV2
        INC HL
        SUB 08
        JP BLKTOALV1
BLKTOALV2:LD C,A
        INC C
        LD A,B
BLKTOALV3:DEC C
        JP Z,BLKTOALV4
        RRCA
        JP BLKTOALV3
BLKTOALV4:LD C,A
        LD A,B
        CP 80
        LD A,(HL)
        JP Z,BLKTOALV5
        AND C
        JP BLKTOALV6
BLKTOALV5:OR C
BLKTOALV6:LD (HL),A
        POP HL
        RET
;
;DIR TRACK&SECTOR SET & READ
DIRSET:PUSH DE
        LD HL,DIRALC
        LD A,(HL)
        LD B,08
        LD C,00
DIRSET1:RLCA
        JP C,DIRSETE
        INC C
        DEC B
        JP NZ,DIRSET1
        INC HL
        LD A,(HL)
        LD B,08
DIRSET2:RLCA
        JP C,DIRSETE
        INC C
        DEC B
        JP NZ,DIRSET2
;
DIRSETE:XOR A
        LD (FNPOS),A
        LD B,00
        CALL BLKTOTS
DIRSETE2:LD HL,DIRTRK
        LD (HL),B
        INC HL
        LD (HL),C
        PUSH BC
        LD C,B
        CALL B_SETTRK
        POP BC
        CALL B_SETSEC
        LD HL,(DIRBFADRS)
        LD B,H
        LD C,L
        CALL B_SETDMA
        CALL B_READ
        LD (FNPOSS),A
        POP DE
        RET
;
;NEXT DIR TRACK&SECTOR SET & READ
NDIRSET:PUSH DE
        LD HL,DIRTRK
        LD B,(HL)
        INC HL
        LD C,(HL)
        INC C
        LD A,(SEC)
        CP C
        JP NZ,DIRSETE2
        LD C,00
        INC B
        JP DIRSETE2
;
;FROM BLOCK NO. TO TRACK,SECTOR
;BC=BLKNo. > B=TRK C=SEC
BLKTOTS:LD A,(BLKSFT);BROCK TO SECTOR
        LD E,A
BLKTOTS1:LD A,C
        OR A
        RLA
        LD C,A
        LD A,B
        RLA
        LD B,A
        DEC E
        JP NZ,BLKTOTS1
;TRACK=BC/SEC SEC must be 2^n
        LD A,(SEC)
        LD D,A
        LD A,C
        DEC D
        AND D
        PUSH AF;SECTOR
        INC D
BLKTOTS2:LD A,D
        RRA
        LD D,A
        JP C,BLKTOTS3
        LD A,B
        RRA
        LD B,A
        LD A,C
        RRA
        LD C,A
        JP BLKTOTS2
BLKTOTS3:LD B,C
        POP AF
        LD C,A;SECTOR
        RET
;

●CP/M互換DOS(仮RAMディスク版)ZBDOSプログラムのアセンブルリスト

アセンブルリストは、ホームページのサイズの関係で、別のページでアップロードしています。
こちらがアセンブルリストです。

ワンボードマイコンでCP/Mを![第154回]
2012.6.18upload

前へ
次へ
ホームページトップへ戻る