0000 * 0001 * 0002 * << DUMP >> 0003 * 0004 * version 1.4.0 8/23/77 D. Williams 0005 * 0006 * 0007 * Dumps contents of file in both hex and ascii to cofil 0008 * 0009 * 0010 * Parameter format: 0011 * 0012 * filename, { FWA }, { LWA } or { >CNT } ; or CR 0013 * 0014 * filename = source file 0015 * FWA = First address ot be outputted 0016 * LWA = Last address to be outputted 0017 * CNT = Number of bytes to be outputted 0018 * 0019 * 0020 * 0021 COPY PTDEFS 0022 * 0023 * 0024 ORG 100H 0025 XEQ 100H 0026 * 0027 * 0028 * 0029 * 0030 LXI SP,STACK+STKSZ SETUP STACK 0031 DUMP CALL INIT Initialize values. 0032 * 0035 CALL SCAN Get FNUM, FWA, and LWA. 0036 * 0037 PCHK LHLD LWA Check parameters. 0038 INX H If LWA = FFFFH, then error. 0039 MOV A,H (LWA max size = FFFEH). 0040 ORA L 0042 CZ ERR6 0043 LHLD FWA Check relative sizes of FWA, LWA. 0044 XCHG . 0045 LHLD LWA 0046 CALL DSUB Compare LWA - FWA. 0047 CC ERR4 FWA must be <= LWA. 0048 * 0049 SPACE LDA FNUM Space forward to FWA. 0050 LHLD FWA 0051 SHLD PLA 0052 MOV B,H 0053 MOV C,L 0054 MVI D,1 0055 CALL SYS 0056 DB SPAOP 0057 JMP SPERR 0058 * 0059 DUMP1 CALL READ Read in line. 0060 * 0061 CALL PROC Convert to desired form. 0062 * 0063 CALL WRITE Output line. 0064 * 0065 LHLD PLA 0066 XCHG . 0067 LHLD BYTRD 0068 DAD D 0069 SHLD PLA Update present line address. 0070 XCHG . 0071 LHLD LWA 0072 CALL DSUB Compare LWA-PLA. 0073 JC DONE If PLA > LWA then done. 0074 * 0075 LDA EOFLG 0076 ORA A 0077 JNZ DONE If EOF flag, then done. 0078 * CALL PAUSE JMP DUMP1 * ***** * * Pause/Halt on SPACEBAR/MODE SELECT. * PAUSE CALL CONTST Key pressed? RZ . No. CALL CONIN Get character. ORA A JZ DONE If MODE SELECT, then done. CPI ' ' JNZ PAUS1 If not BLANK, return it to CI. PAUS2 CALL CONIN If BLANK, pause for another. ORA A JZ DONE If MODE SELECT, then done. CPI ' ' RZ . If BLANK, stop pausing CPI '0' JC PAUS2 If non-digit keep pausing. CPI '9'+1 JNC PAUS2 Likewise. PAUS1 LHLD CHARFL Get address of CHAR. FLAG in SYSGLO. 0090 MOV M,A Set it. RET . 0099 * 0100 * 0101 ******************** 0102 * 0103 * Initialize 0104 * 0105 INIT LHLD SYSGLO Store cofile number in OUTF. 0106 LXI D,GLCOF 0107 DAD D 0108 MOV A,M 0109 STA OUTF * LHLD SYSGLO Store addr. of CHARACTER FLAG in CHARFL. LXI D,GLFLG DAD D SHLD CHARFL 0110 * SET ERROR TRAP FLAGS LHLD SYSGLO LXI D,GLERS DAD D SHLD PTERS MOV A,M STA OLDES MVI M,-1 INX H MOV A,M STA OLDES+1 MVI M,-1 * LHLD SYSGLO LXI D,GLERM DAD D SHLD PTERM MOV A,M STA OLDEM MVI M,-1 INX H MOV A,M STA OLDEM+1 MVI M,-1 * LHLD SYSGLO LXI D,GLERH DAD D SHLD PTERH MOV A,M STA OLDEH MVI M,-1 INX H MOV A,M STA OLDEH+1 MVI M,-1 0120 RET . 0121 * 0122 * 0123 ******************** 0124 * 0125 * Read in min(DWTH, bytes left) bytes. 0126 * 0128 READ CALL MINRD Set A to No. of bytes to be read. 0129 STA RDCNT 0130 MOV C,A Set up RBLOP arguments. 0131 MVI B,0 0132 LDA FNUM 0133 LXI D,BUFF 0134 CALL SYS And read in line from file. 0135 DB RBLOP 0136 CALL RDERR 0137 LDA RDCNT Calculate number of bytes read. 0138 SUB C (Will be different from RDCNT if EOF encountered.) 0139 STA BYTRD 0140 RET . 0141 * 0142 * Calculate min(DWTH, bytes left till LWA). 0143 * 0144 MINRD LHLD PLA 0145 XCHG . 0146 LHLD LWA 0147 INX H 0148 CALL DSUB Calculate (LWA+1)-PLA = bytes left. 0149 XCHG . 0150 LHLD DWTH 0151 CALL DSUB Compare DWTH-(bytes left). 0152 JNC MNRD1 If (bytes left) less, use it. 0153 LHLD DWTH Else, use DWTH. 0154 XCHG . 0155 MNRD1 XCHG . 0156 MOV A,L 0157 RET . 0158 * 0159 * Handle errors from RBLOP. 0160 * 0161 RDERR CPI EREOF 0162 CNZ ERR0 If not EOF, then real error. 0163 LDA RDCNT Else it was EOF. 0164 CMP C 0165 JZ DONE If no bytes were read, then done. 0166 MVI A,TRUE 0167 STA EOFLG If some were, set EOF flag. 0168 RET . And return to output this last line. 0169 * 0170 * 0171 ******************** 0172 * 0173 * Output line to COFIL. 0174 * 0175 WRITE LDA OUTF Set up DWROP arguments. 0176 LHLD LINSZ 0177 MOV B,H 0178 MOV C,L 0179 LXI D,LINE MVI L,0AH Output up to a linefeed. 0180 CALL SYS And output line to COFILE. 0181 DB DWROP 0182 CALL ERR0 CALL CRLF Follow with a crlf. 0183 RET . 0184 * 0185 * 0186 ******************** 0187 * 0188 * When done, close file and return to CI. 0189 * 0190 DONE CALL CRLF CALL RESTOR Restore system to origional state. 0193 CALL SYS Return to CI. 0194 DB RETOP 0195 * 0196 * 0197 ******************** 0198 * 0199 * Close source file. (CLOSE used in DONE, ERR0, and ERROR. 0200 * 0201 CLOSE LDA FNUM Get file number. 0202 CPI 0FFH 0203 RZ . If it was never opened return. 0204 CALL SYS Else, close it. 0205 DB CLOOP 0206 CALL ERR0 0207 RET . 0208 * 0209 * 0210 ******************** 0211 * CRLF CALL CR Output a CR and fall through to LF. 0212 LF LXI D,LFD Output a linefeed. 0213 JMP CR1 0214 CR LXI D,CRD Output a carriage return. 0215 CR1 LDA OUTF 0216 LXI B,1 0217 CALL SYS 0218 DB WBLOP 0219 CALL ERR0 0220 RET . 0221 * 0222 * 0223 ******************** 0224 * 0225 * 16 bit subtract (or compare). HL = HL - DE. 0226 * 0227 DSUB MOV A,L L=L-E. 0228 SUB E 0229 MOV L,A 0230 MOV A,H H=H-D. 0231 SBB D 0232 MOV H,A 0233 RET . 0234 * 0235 * 0236 * 0237 ******************** 0238 * 0239 * Take care of space error, check for EOF. 0240 * 0241 SPERR CPI EREOF 0242 CNZ ERR0 If not EOF, then real error. 0243 JMP DONE Else was EOF so done. 0244 * 0245 * 0246 * 0247 ******************** 0248 * 0249 * 0250 * SCAN for filename, {FWA}, {LWA or >CNT} ; or CR. 0251 * 0252 SCAN MVI A,PSOP Scan for filename, open it. 0253 CALL GET 0254 CZ ERR1 Must have name. 0255 PUSH PSW Save delimiter. 0256 MOV A,E 0257 CPI 0FFH Opened? 0258 CZ ERR5 No, then error. 0259 CALL SAVFN Save file number. 0260 POP PSW Restore delimiter. 0261 CALL HDLM Handle delimiter. 0262 * 0263 GFWA CALL GETV Scan for FWA value. 0264 JZ GFWA1 If none, will be default value (0). 0265 XCHG . 0266 SHLD FWA Save FWA. 0267 GFWA1 CALL HDLM Handle delimiter. 0268 * 0269 GLWA CALL GETV Scan for LWA value. 0270 JZ GLWA1 If none, will be default value (FFFEH). 0271 XCHG . 0272 SHLD LWA Save LWA. 0273 GLWA1 CALL HDLM Handle delimiter. 0274 CALL ERR2 Final delimiter must be ';' or CR. 0275 * 0276 * 0277 * Handle delimiter (in Acc.). Only returns if ','. 0278 * 0279 HDLM CPI ',' Return if ','. 0280 RZ . 0281 POP B If not ',' will return to caller's caller. 0282 CPI '>' If '>' handle count. 0283 CZ HCNT 0284 CPI ';' If ';' done scan. 0285 RZ . 0286 CPI 0DH If CR done scan. 0287 RZ . 0288 CALL ERR2 If not ',' '>' ';' or CR, then error. 0289 * 0290 HCNT CALL GETV Scan for count value. 0291 PUSH PSW 0292 JNZ HCNT1 0293 LXI D,1 If no value, count = 1. 0294 HCNT1 MOV A,D If count=0, then error. 0295 ORA E 0296 CZ ERR2 0297 POP PSW 0298 LHLD FWA Get FWA, 0299 DAD D add count, 0300 DCX H and subtract 1, 0301 SHLD LWA to get LWA. Store LWA. 0302 RET . 0303 * 0304 * 0305 * 0306 GETV MVI A,PSV Scan for value. 0307 GET LXI D,SBUF 0308 CALL PSCAN 0309 CC PSERR 0310 RET . 0311 * 0312 * 0313 * Save file number. (presently in D). 0314 * 0315 SAVFN MOV A,D 0316 ORA A 0317 CNZ ERR3 File number > 255. 0318 MOV A,E 0319 STA FNUM Save file number in FNUM. 0320 RET . 0321 * 0322 * 0323 * Handel errors returned from PSCAN. 0324 * 0325 PSERR MOV A,E 0326 ORA A 0327 CNZ ERRPS If E<>0, then PTDOS error. 0328 CALL ERR7 Else, it's a field error. 0329 * 0330 * 0331 * 0332 ******************** 0333 * 0334 * 0335 * Convert bytes read in into ascii hex * and ascii for output. 0336 * 0337 PROC CALL PINIT Initialize BUFPT,HEXPT,ASCPT,and loop coun 0338 * 0339 CALL BLANK Blank out output area. 0340 * 0341 LDA PLA+1 Put ascii hex value of present line 0342 LXI H,LINE address into output line. 0343 CALL HEXER 0344 LDA PLA 0345 LXI H,LINE+2 0346 CALL HEXER 0347 * 0348 PROC1 LHLD BUFPT Get current byte from buffer. 0349 MOV A,M 0350 INX H 0351 SHLD BUFPT 0352 * 0353 PUSH PSW Save current byte for later. 0354 LHLD HEXPT Put ascii hex value of byte 0355 CALL HEXER into output line. 0356 INX H 0357 INX H 0358 SHLD HEXPT 0359 POP PSW Recall current byte. 0360 ANI 7FH Mask off parity bit. 0361 * 0362 LHLD ASCPT Put ascii into output line. 0363 MVI M,NONPR By first putting default character there. 0364 CPI LOWCH If byte is a non-printing 0365 JC PROC2 ascii character, 0366 CPI HICH+1 then leave default character 0367 JNC PROC2 in output line. 0368 MOV M,A Else, put the ascii character in. 0369 PROC2 INX H 0370 SHLD ASCPT 0371 * 0372 INR C Increment loop count. 0373 * 0374 LDA BYTRD 0375 CMP C Should go through once for 0376 RZ 0377 RC 0378 JMP PROC1 each byte read into buffer. 0379 * 0380 * Store value of A as two hex digits at addresses HL & HL 0381 * 0382 HEXER MOV B,A Store A for later. 0383 RAR . Rotate high bits into position for processing. 0384 RAR . 0385 RAR . 0386 RAR . 0387 CALL HEX4 Process first (high) digit. 0388 INX H 0389 MOV A,B Restore A and fall through for second (low) digit 0390 HEX4 ANI 15 Mask digit. 0391 ADI '0' 0392 CPI '9'+1 Is it a number? 0393 JC STOR Yes, then store it. 0394 ADI 7 No, then make it a letter. 0395 STOR MOV M,A Store it. 0396 RET . 0397 * 0398 * Initialize BUFPT, HEXPT, ASCPT, and loop count. 0399 * 0400 PINIT LXI H,BUFF Initialize BUFPT to point to 0401 SHLD BUFPT start of buffer area. 0402 LXI H,LINE Initialize HEXPT to point to 0403 LXI D,7 where the first hex value 0404 DAD D should go. 0405 SHLD HEXPT 0406 XCHG . Initialize ASCPT to point to 0407 LHLD DWTH where first ascii value 0408 XCHG . should go. 0409 DAD D 0410 DAD D 0411 DAD D 0412 LXI D,2 0413 DAD D 0414 SHLD ASCPT 0415 MVI C,0 Initialize loop count to zero. 0416 RET . 0417 * 0418 * Blank out output line. 0419 * 0420 BLANK LXI H,LINE 0421 MVI D,20H 0422 LDA LINSZ 0423 BLNK1 MOV M,D 0424 INX H 0425 DCR A 0426 JNZ BLNK1 0427 RET . 0428 * 0429 * 0430 * 0431 ******************** 0432 * 0433 * 0434 * Error handler. 0435 * 0436 * ERR0 handles system defined errors. 0437 * 0438 ERR0 STA ERCOD Save error number 0439 CALL RESTOR Restore system to origional state. 0443 POP H 0444 DCX H 0445 DCX H 0446 DCX H DCX H MOV A,M INX H STA CMCOD MVI A,3 Print "called from", reset. CALL UTIL DB UXOP JMP ERR01 CMCOD DB 0 ERCOD DB 0 * ERR01 CALL SYS DB SREOP * DB -1 ERRPS CALL ERR0 Handle PSCAN errors. 0449 * 0450 * Other error numbers are for errors unique to DUMP. 0451 * They will print out a message and then call sreset. 0452 * 0453 ERR1 CALL ERROR 0454 ASC "File name required." DB 0 0455 ERR2 CALL ERROR 0456 ASC "Improper arguments." DB 0 0457 ERR3 CALL ERROR 0458 ASC "File number to large." DB 0 0459 ERR4 CALL ERROR 0460 ASC "First address larger than last address." DB 0 0461 ERR5 CALL ERROR 0462 ASC "Illegal file name." DB 0 0463 ERR6 CALL ERROR 0464 ASC "LWA to large,(max=FFFEH)." DB 0 0465 ERR7 CALL ERROR 0466 ASC "Syntax error." DB 0 0467 * ERROR CALL RESTOR Restore system to origional state. LXI D,ERRMS CALL PRINT Print "DUMP ERROR: ". POP D Get address of error message. CALL PRINT Print error message. MVI A,0DH Print carriage return, linefeed. CALL CONOUT MVI A,0AH CALL CONOUT 0479 CALL SYS 0480 DB SREOP And finally reset. 0481 * 0482 ********** 0483 * PRINT LDAX D ORA A RZ . CALL CONOUT INX D JMP PRINT * * **************************************** * * Restore system to origional state. * RESTOR CALL CLOSE Close source file. LHLD PTERS Restore error trap flags. LDA OLDES MOV M,A INX H LDA OLDES+1 MOV M,A LHLD PTERM LDA OLDEM MOV M,A INX H LDA OLDEM+1 MOV M,A LHLD PTERH LDA OLDEH MOV M,A INX H LDA OLDEH+1 MOV M,A RET . * 0484 *********************************************************** 0485 * 0486 * 0487 * Definition of constants and storage area. 0488 * 0489 * 0490 DWTH DW 12 Number of bytes dumped per line (max 32). 0491 LINSZ DW 63 Size of output line (max 137). 0492 LINE DS 139 Output line (room for largest LINESZ+crlf). 0493 BUFF DS 32 Read buffer (Room for largest dwth). 0494 STKSZ EQU 30 Size of stack. 0495 STACK DS STKSZ Stack. 0496 SBUF DS 25 Pscan buffer. 0497 * 0498 FWA DW 0 First word address. 0499 LWA DW 0FFFEH Last word address. 0500 FNUM DB 0FFH File number. 0501 PLA DW 0 Present line address. 0502 BUFPT DW 0 Pointer into read buffer. 0503 ASCPT DW 0 Pointer into ascii field of output line. 0504 HEXPT DW 0 Pointer into hex field of output line. 0505 BYTRD DW 0 Bytes read on last read of input file. 0506 RDCNT DB 0 Bytes to be read on next read of input file. 0507 * 0508 OUTF DB 0 COFILE number. 0509 EOFLG DB 0 EOF flag. 0510 TRUE EQU 1 Boolean constant. 0511 CRD DB 0DH Carriage return data. 0512 LFD DB 0AH Linefeed data. CHARFL DW 0 Address of char. flag in SYSGLO area. * PTERS DW 0 Pointer to level 2 error trap flag. OLDES DW 0 Old value of level 2 error trap flag. PTERM DW 0 Pointer to level 1 error trap flag. OLDEM DW 0 Old value of level 1 error trap flag. PTERH DW 0 Pointer to level 0 error trap flag. OLDEH DW 0 Old value of level 0 error trap flag. 0513 * 0514 LOWCH EQU 20H Lowest ascii printable character (blank). 0515 HICH EQU 7EH Highest ascii printable character. 0516 NONPR EQU '.' Char. to substitute for non-printable one. 0517 * ERRMS ASC "DUMP ERROR: " DB 0 * 0521 * 0522 *********************************************************** 0523 END 0524 *