復活!CP/M ワンボードマイコンでCP/Mを!
CP/MがTK−80互換のワンボードマイコンの上で復活します
ND80ZVとMYCPU80の上でCP/Mが走ります!
[第109回]
●ファンクションコール23H(ファイルサイズの取得)
ファンクションコール23Hは、ファイルサイズを取得してFCBエリアの末尾3バイトに入れます。
シーケンシャルファイルもランダムファイルもどちらも読み出せます。
●テストプログラムFTST22.TXT
ファンクションコール23HのテストプログラムFTST22.TXTのソースリストです。
; BDOS TEST22 function23 file size get ;2012/3/4 3/7 4/16 4/17 4/27 ; ORG $8100 FCALL=$8005 NMBRTBL=$8300 FCB=$805C FCBR0=$807D FCBR1=$807E FCBR2=$807F DMA=$8080 ; LD C,0F;open file LD DE,FCB CALL FCALL INC A;if FFH? JP Z,OPENERR ; LD C,23;file size read LD DE,FCB CALL FCALL ; LD A,(FCBR2) CALL B2HEXDP CALL SPDP LD A,(FCBR1) CALL B2HEXDP CALL SPDP LD A,(FCBR0) CALL B2HEXDP CALL CRLF LD DE,OK JP MSGOUT ; OPENERR:LD DE,CANTOPN MSGOUT:LD C,09 CALL FCALL RET ; ;CL & LF CRLF:LD A,0D CALL ADP LD A,0A JP ADP ;space disp SPDP:LD A,20 ;A disp ADP:PUSH BC PUSH HL LD E,A LD C,02 CALL FCALL POP HL POP BC RET ;binary to hex, 2bytes data to ascii 4charactors,HL to HL,DE B2HEX4:LD A,H CALL B2HEX2 EX DE,HL LD A,E ;binary to hex, 1byte data to ascii 2charactors,A to DE B2HEX2:PUSH AF RRCA RRCA RRCA RRCA CALL B2HEX1 LD D,A POP AF CALL B2HEX1 LD E,A RET ;binary to hex, low 4bit to ascii 1charactor B2HEX1:AND 0F ADD A,30 CP 3A RET C;0-9 ADD A,07;A-F RET ;hex to binary, ascii 1charactor to low 4bit HTOB1:CP 30;>="0"? RET C;no CP 3A;<="9"? JP C,HTOB1_2;yes,"0" to "9" CP 41;>="A" ? RET C;no CP 47;<="F"? JP C,HTOB1_1 CP 61;>="a"? RET C;no CP 67;<="f"? CCF RET C;no HTOB1_1:ADD A,09;41 to 46 -> 4A to 4F,or 61 to 67 -> 6A to 6F HTOB1_2:AND 0F RET ;HL(bynary 2bytes) to asckii 4bytes & disp HEX4DP:PUSH BC PUSH HL CALL B2HEX4;binary 2 bytes to ascii HEX 4bytes PUSH DE EX DE,HL CALL DEDP POP DE CALL DEDP POP HL POP BC RET ;A(binary) to asckii 2bytes HEX & disp B2HEXDP:PUSH BC PUSH HL CALL B2HEX2 CALL DEDP POP HL POP BC RET ; ;DE(asckii 2bytes) disp DEDP:PUSH DE LD E,D LD C,02 CALL FCALL POP DE LD C,02 CALL FCALL RET ; CANTOPN:"can'" "t op" "en!" DB 0D DB 0A DB 24;$ OK:"end" DB 0D DB 0A DB 24;$ ; |
2012/4/27 18: ftst22.txt END=81CD ; BDOS TEST22 function23 file size get ;2012/3/4 3/7 4/16 4/17 4/27 ; ORG $8100 FCALL=$8005 NMBRTBL=$8300 FCB=$805C FCBR0=$807D FCBR1=$807E FCBR2=$807F DMA=$8080 ; 8100 0E0F LD C,0F;open file 8102 115C80 LD DE,FCB 8105 CD0580 CALL FCALL 8108 3C INC A;if FFH? 8109 CA3581 JP Z,OPENERR ; 810C 0E23 LD C,23;file size read 810E 115C80 LD DE,FCB 8111 CD0580 CALL FCALL ; 8114 3A7F80 LD A,(FCBR2) 8117 CDA181 CALL B2HEXDP 811A CD4881 CALL SPDP 811D 3A7E80 LD A,(FCBR1) 8120 CDA181 CALL B2HEXDP 8123 CD4881 CALL SPDP 8126 3A7D80 LD A,(FCBR0) 8129 CDA181 CALL B2HEXDP 812C CD3E81 CALL CRLF 812F 11C881 LD DE,OK 8132 C33881 JP MSGOUT ; 8135 11BA81 OPENERR:LD DE,CANTOPN 8138 0E09 MSGOUT:LD C,09 813A CD0580 CALL FCALL 813D C9 RET ; ;CL & LF 813E 3E0D CRLF:LD A,0D 8140 CD4A81 CALL ADP 8143 3E0A LD A,0A 8145 C34A81 JP ADP ;space disp 8148 3E20 SPDP:LD A,20 ;A disp 814A C5 ADP:PUSH BC 814B E5 PUSH HL 814C 5F LD E,A 814D 0E02 LD C,02 814F CD0580 CALL FCALL 8152 E1 POP HL 8153 C1 POP BC 8154 C9 RET ;binary to hex, 2bytes data to ascii 4charactors,HL to HL,DE 8155 7C B2HEX4:LD A,H 8156 CD5B81 CALL B2HEX2 8159 EB EX DE,HL 815A 7B LD A,E ;binary to hex, 1byte data to ascii 2charactors,A to DE 815B F5 B2HEX2:PUSH AF 815C 0F RRCA 815D 0F RRCA 815E 0F RRCA 815F 0F RRCA 8160 CD6A81 CALL B2HEX1 8163 57 LD D,A 8164 F1 POP AF 8165 CD6A81 CALL B2HEX1 8168 5F LD E,A 8169 C9 RET ;binary to hex, low 4bit to ascii 1charactor 816A E60F B2HEX1:AND 0F 816C C630 ADD A,30 816E FE3A CP 3A 8170 D8 RET C;0-9 8171 C607 ADD A,07;A-F 8173 C9 RET ;hex to binary, ascii 1charactor to low 4bit 8174 FE30 HTOB1:CP 30;>="0"? 8176 D8 RET C;no 8177 FE3A CP 3A;<="9"? 8179 DA8D81 JP C,HTOB1_2;yes,"0" to "9" 817C FE41 CP 41;>="A" ? 817E D8 RET C;no 817F FE47 CP 47;<="F"? 8181 DA8B81 JP C,HTOB1_1 8184 FE61 CP 61;>="a"? 8186 D8 RET C;no 8187 FE67 CP 67;<="f"? 8189 3F CCF 818A D8 RET C;no 818B C609 HTOB1_1:ADD A,09;41 to 46 -> 4A to 4F,or 61 to 67 -> 6A to 6F 818D E60F HTOB1_2:AND 0F 818F C9 RET ;HL(bynary 2bytes) to asckii 4bytes & disp 8190 C5 HEX4DP:PUSH BC 8191 E5 PUSH HL 8192 CD5581 CALL B2HEX4;binary 2 bytes to ascii HEX 4bytes 8195 D5 PUSH DE 8196 EB EX DE,HL 8197 CDAC81 CALL DEDP 819A D1 POP DE 819B CDAC81 CALL DEDP 819E E1 POP HL 819F C1 POP BC 81A0 C9 RET ;A(binary) to asckii 2bytes HEX & disp 81A1 C5 B2HEXDP:PUSH BC 81A2 E5 PUSH HL 81A3 CD5B81 CALL B2HEX2 81A6 CDAC81 CALL DEDP 81A9 E1 POP HL 81AA C1 POP BC 81AB C9 RET ; ;DE(asckii 2bytes) disp 81AC D5 DEDP:PUSH DE 81AD 5A LD E,D 81AE 0E02 LD C,02 81B0 CD0580 CALL FCALL 81B3 D1 POP DE 81B4 0E02 LD C,02 81B6 CD0580 CALL FCALL 81B9 C9 RET ; 81BA 63616E27 CANTOPN:"can'" 81BE 74206F70 "t op" 81C2 656E21 "en!" 81C5 0D DB 0D 81C6 0A DB 0A 81C7 24 DB 24;$ 81C8 656E64 OK:"end" 81CB 0D DB 0D 81CC 0A DB 0A 81CD 24 DB 24;$ ; ADP =814A B2HEX1 =816A B2HEX2 =815B B2HEX4 =8155 B2HEXDP =81A1 CANTOPN =81BA CRLF =813E DEDP =81AC DMA =8080 FCALL =8005 FCB =805C FCBR0 =807D FCBR1 =807E FCBR2 =807F HEX4DP =8190 HTOB1 =8174 HTOB1_1 =818B HTOB1_2 =818D MSGOUT =8138 NMBRTBL =8300 OK =81C8 OPENERR =8135 SPDP =8148 |
ND80ZVに接続しました 0001 0000 - z 1000 00C3 - *** nd80z3 basic **** >/ld ftst22.bin,8100 loading FTST22.BIN ...00ce(206)bytes loaded,from 8100 to 81CD >jp d233 a>b: b>dir B: TEST RAF : FTST21 COM b>era ftst21.com b>save 1 ftst22.com b>ftst22 a:test.raf 00 03 B7 end b>ftst22 test.raf 00 03 B7 end b> |
b>ftst22 a:ftst20-2.com 00 00 02 end b>ftst22 ftst22.com 00 00 02 end b> |