0001 ;============================================================== 0002 ; 0003 ; Program DDUMP (d:) 0004 ; 0005 ; DDUMP displays a hex dump of all disk directory entries, in 0006 ; their physical order, at the console. The display format is: 0007 ; 0008 ; uu ff ff ff ff ff ff ff ff tt tt tt ex s1 s2 rc filename typ 0009 ; mm mm mm mm mm mm mm mm mm mm mm mm mm mm mm mm 0010 ; 0011 ; where uu = the user number/activity flag in hex 0012 ; ff..ff = the filename in hex 0013 ; tt..tt = the filetype in hex 0014 ; ex = the extent number in hex 0015 ; s1, s2 = the reserved system bytes in hex 0016 ; rc = the record count byte in hex 0017 ; mm..mm = the data map in hex 0018 ; 0019 ; The only operand is a drivecode, e.g. "B:" (a complete fileref 0020 ; may be given, but only the drivecode has any effect). That 0021 ; drive's directory will be dumped. 0022 ; ***************************************************** 0023 ; * This program was originally published in * 0024 ; * A PROGRAMMER'S NOTEBOOK * 0025 ; * Utilities for CP/M-80 * 0026 ; * by David E. Cortesi * 0027 ; * Copyright (C) Reston Publishing Company Inc. 1983 * 0028 ; ***************************************************** 0029 ;============================================================== 0030 MACLIB CPMEQU 0031 MACLIB PROG 0032 PROLOG 0033 ;============================================================== 0034 ; The main program... 0035 Main: 0036 ; 0037 call SetDrivecode ; set default drive and FCB 0038 ; 0039 call FirstSearch 0040 MainLoop: 0041 mov a,l 0042 ora h 0043 rz ; terminate when no more entries 0044 call Display ; display this entry 0045 call NextSearch ; get the next one 0046 JMPR MainLoop 0047 ;--------------------------------------------------------------- 0048 ; FirstSearch(var P): Perform the BDOS Search-first operation. 0049 ; preserves - AF, BC, DE 0050 ; returns - HL->dir. entry, or HL=0000 0051 ; note -- exits via MakeAddr, common code with NextSearch 0052 ;--------------------------------------------------------------- 0053 FirstSearch: 0054 push psw 0055 ; 0056 SERVICE BdosSrch1,CpmFcb 0057 JMPR MakeAddr 0058 ;--------------------------------------------------------------- 0059 ; NextSearch(var P): Perform the BDOS Search-next operation 0060 ; preserves - AF, BC, DE 0061 ; returns - HL->dir. entry, or HL=0000 0062 ;--------------------------------------------------------------- 0063 NextSearch: 0064 push psw 0065 ; 0066 SERVICE BdosSrchn,CpmFcb 0067 ; 0068 MakeAddr: 0069 lxi h,0 0070 ora a ; A=FFh? 0071 jm MakeAdout 0072 add a ; offset * 2 0073 add a ; * 4 0074 add a ; * 8 0075 add a ; * 16 0076 add a ; * 32 0077 ori CpmBuffer ; address in base page 0078 mvi h,CpmBasePage 0079 mov l,a 0080 MakeAdOut: 0081 pop psw 0082 ret 0083 ;--------------------------------------------------------------- 0084 ; Display(P) : dump HL->directory entry at the console. 0085 ; preserves -- all 0086 ;--------------------------------------------------------------- 0087 Display: 0088 push psw 0089 push b 0090 push h 0091 ; 0092 call TypeCRLF ; start with a blank line 0093 call Dump16 ; hex-dump the first half 0094 call TypeBlank ; two spaces before filename 0095 call TypeBlank 0096 ; 0097 ; we can't use TypeMessage to type "filenametyp" -- dollar 0098 ; signs are legal in filerefs! 0099 ; 0100 mvi b,8+3 ; length to type 0101 DispLoop2: 0102 inx h ; HL->next filename/typ byte 0103 mov a,m 0104 call TypeChar 0105 DJNZ DispLoop2 0106 call TypeCRLF ; end the first line 0107 ; 0108 ; now do the second line. HL->last "typ" byte... 0109 ; 0110 lxi b,5 ; offset to data map 0111 dad b ; HL->data map 0112 call Dump16 ; dump the data map, 0113 call TypeCRLF ; end the second line 0114 ; 0115 pop h 0116 pop b 0117 pop psw 0118 ret 0119 ;--------------------------------------------------------------- 0120 ; Dump16 : dump the 16 bytes addressed by HL. 0121 ; preserves - all 0122 ;--------------------------------------------------------------- 0123 Dump16: 0124 push psw 0125 push b 0126 push h 0127 ; 0128 mvi b,16 0129 DumpLoop: 0130 mov a,m 0131 call TypeXX ; two hex digits, 0132 call TypeBlank ; then a blank, 0133 inx h 0134 DJNZ DumpLoop ; 16 times. 0135 ; 0136 pop h 0137 pop b 0138 pop psw 0139 ret 0140 ;--------------------------------------------------------------- 0141 ; SetDriveCode: if a drivecode was given, make that the default 0142 ; drive -- the full-search request works only on the default 0143 ; drive. Then set the FCB drivecode to "?". 0144 ; preserves -- all 0145 ;--------------------------------------------------------------- 0146 SetDriveCode: 0147 push psw 0148 push d 0149 ; 0150 lda CpmFcb 0151 ora a ; drivecode given? 0152 JRZ SetDrive2 ; (no -- present drive is OK) 0153 dcr a ; yes, adjust for service 0154 mov e,a 0155 SERVICE BdosSetDrive 0156 SetDrive2: 0157 mvi a,'?' 0158 sta CpmFcb 0159 ; 0160 pop d 0161 pop psw 0162 ret 0163 ;=============================================================== 0164 ; included subroutines... 0165 ; #include TypeSubs.Inc,TypeCommon -- TypeChar, -CRLF, etc. 0166 ; #include TypeSubs.Inc,TypeXX 0167 end * CROSS-REFERENCE * def. val. symbol and uses * ---- 000E BDOSSETDRIVE SERVICE-155 * ---- 0011 BDOSSRCH1 SERVICE-56 * ---- 0012 BDOSSRCHN SERVICE-66 * ---- 0000 CPMBASEPAGE MVI-78 * ---- 0080 CPMBUFFER ORI-77 * ---- 005C CPMFCB SERVICE-56 -66 LDA-150 STA-158 * 0087 019C DISPLAY CALL-44 * 0101 01AD DISPLOOP2 DJNZ-105 * 0123 01C7 DUMP16 CALL-93 -112 * 0129 01CC DUMPLOOP DJNZ-134 * 0053 0168 FIRSTSEARCH CALL-39 * 0035 0156 MAIN * 0040 015C MAINLOOP JMPR-46 * 0068 0189 MAKEADDR JMPR-57 * 0080 019A MAKEADOUT JM-71 * 0063 017A NEXTSEARCH CALL-45 * 0156 01F2 SETDRIVE2 JRZ-152 * 0146 01DC SETDRIVECODE CALL-37 * ---- 01FA TYPEBLANK CALL-94 -95 -132 * ---- 0219 TYPECHAR CALL-104 * ---- 0200 TYPECRLF CALL-92 -106 -113 * ---- 0228 TYPEXX CALL-131 * CENSUS OF OPCODE USAGE * * ADD 5 CALL 14 DAD 1 * DCR 1 DJNZ 2 END 1 * INX 2 JM 1 JMPR 2 * JRZ 1 LDA 1 LXI 2 * MACLIB 2 MOV 5 MVI 4 * ORA 3 ORI 1 POP 9 * PROLOG 1 PUSH 10 RET 4 * RZ 1 SERVICE 3 STA 1