dump.asm 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. ; FILE DUMP PROGRAM, READS AN INPUT FILE AND PRINTS IN HEX
  2. ;
  3. ; COPYRIGHT (C) 1975, 1976, 1977, 1978
  4. ; DIGITAL RESEARCH
  5. ; BOX 579, PACIFIC GROVE
  6. ; CALIFORNIA, 93950
  7. ;
  8. ORG 100H
  9. BDOS EQU 0005H ;DOS ENTRY POINT
  10. CONS EQU 1 ;READ CONSOLE
  11. TYPEF EQU 2 ;TYPE FUNCTION
  12. PRINTF EQU 9 ;BUFFER PRINT ENTRY
  13. BRKF EQU 11 ;BREAK KEY FUNCTION (TRUE IF CHAR READY)
  14. OPENF EQU 15 ;FILE OPEN
  15. READF EQU 20 ;READ FUNCTION
  16. ;
  17. FCB EQU 5CH ;FILE CONTROL BLOCK ADDRESS
  18. BUFF EQU 80H ;INPUT DISK BUFFER ADDRESS
  19. ;
  20. ; NON GRAPHIC CHARACTERS
  21. CR EQU 0DH ;CARRIAGE RETURN
  22. LF EQU 0AH ;LINE FEED
  23. ;
  24. ; FILE CONTROL BLOCK DEFINITIONS
  25. FCBDN EQU FCB+0 ;DISK NAME
  26. FCBFN EQU FCB+1 ;FILE NAME
  27. FCBFT EQU FCB+9 ;DISK FILE TYPE (3 CHARACTERS)
  28. FCBRL EQU FCB+12 ;FILE'S CURRENT REEL NUMBER
  29. FCBRC EQU FCB+15 ;FILE'S RECORD COUNT (0 TO 128)
  30. FCBCR EQU FCB+32 ;CURRENT (NEXT) RECORD NUMBER (0 TO 127)
  31. FCBLN EQU FCB+33 ;FCB LENGTH
  32. ;
  33. ; SET UP STACK
  34. LXI H,0
  35. DAD SP
  36. ; ENTRY STACK POINTER IN HL FROM THE CCP
  37. SHLD OLDSP
  38. ; SET SP TO LOCAL STACK AREA (RESTORED AT FINIS)
  39. LXI SP,STKTOP
  40. ; READ AND PRINT SUCCESSIVE BUFFERS
  41. CALL SETUP ;SET UP INPUT FILE
  42. CPI 255 ;255 IF FILE NOT PRESENT
  43. JNZ OPENOK ;SKIP IF OPEN IS OK
  44. ;
  45. ; FILE NOT THERE, GIVE ERROR MESSAGE AND RETURN
  46. LXI D,OPNMSG
  47. CALL ERR
  48. JMP FINIS ;TO RETURN
  49. ;
  50. OPENOK: ;OPEN OPERATION OK, SET BUFFER INDEX TO END
  51. MVI A,80H
  52. STA IBP ;SET BUFFER POINTER TO 80H
  53. ; HL CONTAINS NEXT ADDRESS TO PRINT
  54. LXI H,0 ;START WITH 0000
  55. ;
  56. GLOOP:
  57. PUSH H ;SAVE LINE POSITION
  58. CALL GNB
  59. POP H ;RECALL LINE POSITION
  60. JC FINIS ;CARRY SET BY GNB IF END FILE
  61. MOV B,A
  62. ; PRINT HEX VALUES
  63. ; CHECK FOR LINE FOLD
  64. MOV A,L
  65. ANI 0FH ;CHECK LOW 4 BITS
  66. JNZ NONUM
  67. ; PRINT LINE NUMBER
  68. CALL CRLF
  69. ;
  70. ; CHECK FOR BREAK KEY
  71. CALL BREAK
  72. ; ACCUM LSB = 1 IF CHARACTER READY
  73. RRC ;INTO CARRY
  74. JC FINIS ;DON'T PRINT ANY MORE
  75. ;
  76. MOV A,H
  77. CALL PHEX
  78. MOV A,L
  79. CALL PHEX
  80. NONUM:
  81. INX H ;TO NEXT LINE NUMBER
  82. MVI A,' '
  83. CALL PCHAR
  84. MOV A,B
  85. CALL PHEX
  86. JMP GLOOP
  87. ;
  88. FINIS:
  89. ; END OF DUMP, RETURN TO CCP
  90. ; (NOTE THAT A JMP TO 0000H REBOOTS)
  91. CALL CRLF
  92. LHLD OLDSP
  93. SPHL
  94. ; STACK POINTER CONTAINS CCP'S STACK LOCATION
  95. RET ;TO THE CCP
  96. ;
  97. ;
  98. ; SUBROUTINES
  99. ;
  100. BREAK: ;CHECK BREAK KEY (ACTUALLY ANY KEY WILL DO)
  101. PUSH H! PUSH D! PUSH B; ENVIRONMENT SAVED
  102. MVI C,BRKF
  103. CALL BDOS
  104. POP B! POP D! POP H; ENVIRONMENT RESTORED
  105. RET
  106. ;
  107. PCHAR: ;PRINT A CHARACTER
  108. PUSH H! PUSH D! PUSH B; SAVED
  109. MVI C,TYPEF
  110. MOV E,A
  111. CALL BDOS
  112. POP B! POP D! POP H; RESTORED
  113. RET
  114. ;
  115. CRLF:
  116. MVI A,CR
  117. CALL PCHAR
  118. MVI A,LF
  119. CALL PCHAR
  120. RET
  121. ;
  122. ;
  123. PNIB: ;PRINT NIBBLE IN REG A
  124. ANI 0FH ;LOW 4 BITS
  125. CPI 10
  126. JNC P10
  127. ; LESS THAN OR EQUAL TO 9
  128. ADI '0'
  129. JMP PRN
  130. ;
  131. ; GREATER OR EQUAL TO 10
  132. P10: ADI 'A' - 10
  133. PRN: CALL PCHAR
  134. RET
  135. ;
  136. PHEX: ;PRINT HEX CHAR IN REG A
  137. PUSH PSW
  138. RRC
  139. RRC
  140. RRC
  141. RRC
  142. CALL PNIB ;PRINT NIBBLE
  143. POP PSW
  144. CALL PNIB
  145. RET
  146. ;
  147. ERR: ;PRINT ERROR MESSAGE
  148. ; D,E ADDRESSES MESSAGE ENDING WITH "$"
  149. MVI C,PRINTF ;PRINT BUFFER FUNCTION
  150. CALL BDOS
  151. RET
  152. ;
  153. ;
  154. GNB: ;GET NEXT BYTE
  155. LDA IBP
  156. CPI 80H
  157. JNZ G0
  158. ; READ ANOTHER BUFFER
  159. ;
  160. ;
  161. CALL DISKR
  162. ORA A ;ZERO VALUE IF READ OK
  163. JZ G0 ;FOR ANOTHER BYTE
  164. ; END OF DATA, RETURN WITH CARRY SET FOR EOF
  165. STC
  166. RET
  167. ;
  168. G0: ;READ THE BYTE AT BUFF+REG A
  169. MOV E,A ;LS BYTE OF BUFFER INDEX
  170. MVI D,0 ;DOUBLE PRECISION INDEX TO DE
  171. INR A ;INDEX=INDEX+1
  172. STA IBP ;BACK TO MEMORY
  173. ; POINTER IS INCREMENTED
  174. ; SAVE THE CURRENT FILE ADDRESS
  175. LXI H,BUFF
  176. DAD D
  177. ; ABSOLUTE CHARACTER ADDRESS IS IN HL
  178. MOV A,M
  179. ; BYTE IS IN THE ACCUMULATOR
  180. ORA A ;RESET CARRY BIT
  181. RET
  182. ;
  183. SETUP: ;SET UP FILE
  184. ; OPEN THE FILE FOR INPUT
  185. XRA A ;ZERO TO ACCUM
  186. STA FCBCR ;CLEAR CURRENT RECORD
  187. ;
  188. LXI D,FCB
  189. MVI C,OPENF
  190. CALL BDOS
  191. ; 255 IN ACCUM IF OPEN ERROR
  192. RET
  193. ;
  194. DISKR: ;READ DISK FILE RECORD
  195. PUSH H! PUSH D! PUSH B
  196. LXI D,FCB
  197. MVI C,READF
  198. CALL BDOS
  199. POP B! POP D! POP H
  200. RET
  201. ;
  202. ; FIXED MESSAGE AREA
  203. SIGNON: DB 'FILE DUMP VERSION 1.4$'
  204. OPNMSG: DB CR,LF,'NO INPUT FILE PRESENT ON DISK$'
  205. ; VARIABLE AREA
  206. IBP: DS 2 ;INPUT BUFFER POINTER
  207. OLDSP: DS 2 ;ENTRY SP VALUE FROM CCP
  208. ;
  209. ; STACK AREA
  210. DS 64 ;RESERVE 32 LEVEL STACK
  211. STKTOP:
  212. ;
  213. END
  214.