home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol165 / dummp.asn < prev    next >
Encoding:
Text File  |  1984-07-09  |  5.5 KB  |  348 lines

  1.  
  2. ;    -----------------------------------------------------------
  3. ;    DUMP.COM is a utility provided by Digital Research in their
  4. ;    CP/M package. However, it is convenient to supplement the
  5. ;    original program with some additional features, as well as
  6. ;    cleaning up the code which is based on their PL/M compiler.
  7. ;    Accordingly, the display line formed from a serial address
  8. ;    and sixteen hexadecimal bytes is supplemented by the ASCII
  9. ;    interpretation of these same bytes, as is done by DDT. If
  10. ;    desired, the whole display may be recorded on disk, and
  11. ;    later edited or printed. Error checking is very lenient.
  12. ;
  13. ;            DUMMP.ASN   Copyright (C) 1983
  14. ;            Universidad Autonoma de Puebla
  15. ;                   November 15, 1983
  16. ;
  17. ;    [Harold V. McIntosh, 15 November 1983]
  18. ;    -----------------------------------------------------------
  19.  
  20. BDOS    equ    224        ;CP/M interrupt to BDOS
  21.  
  22. TFCB    equ    5CH        ;file control block address
  23. DSIZ    equ    200H        ;size of .DDD buffer
  24. TSIZ    equ    80H        ;size of input buffer
  25. TBUF    equ    80H        ;input buffer address
  26.  
  27. ;    Non-graphic characters
  28.  
  29. CR    equ    0DH        ;carriage return
  30. LF    equ    0AH        ;line feed
  31.  
  32.  
  33. ;    -------------
  34.     org    0100H
  35. ;    -------------
  36.  
  37. BEGN:    cmpb    TFCB+1,#' '
  38.     jnz    NNUL
  39.     ld    bx,#LOGO
  40.     call    MSSG
  41.     jmp    EXIT
  42.  
  43. NNUL:    ld    bx,#(TFCB+9)
  44.     cmpb    [bx],#' '
  45.     jnz    YEXT
  46.     stob    #'C',[bx]
  47.     inc    bx
  48.     stob    #'M',[bx]
  49.     inc    bx
  50.     stob    #'D',[bx]
  51.  
  52. YEXT:    stob    #0,DOUT        ;z=no .DDD file
  53.     ld    bx,#(TFCB+17)
  54.     cmpb    [bx],#' '
  55.     jz    OPFI
  56.  
  57. ;    If a listing file is specified, set it up.
  58.  
  59.     ld    ah,#12
  60.     ld    dx,#DFCB    ;.DDD FCB
  61.     ld    bx,#(TFCB+16)
  62. DMOV:    ld    al,[bx]
  63.     xchg    bx,dx
  64.     sto    al,[bx]
  65.     xchg    bx,dx
  66.     inc    bx
  67.     inc    dx
  68.     dec    ah
  69.     jnz    DMOV
  70.  
  71. ;    Beware that the same file will not be source and listing.
  72.  
  73.     ld    ah,#11
  74.     ld    bx,#(TFCB+1)
  75.     ld    dx,#(DFCB+1)
  76. DCHK:    ld    al,[bx]
  77.     xchg    bx,dx
  78.     cmp    al,[bx]
  79.     xchg    bx,dx
  80.     jnz    DINI
  81.     inc    bx
  82.     inc    dx
  83.     dec    ah
  84.     jnz    DCHK
  85.     ld    bx,#SAME
  86.     call    MSSG
  87.     jmp    EXIT
  88.  
  89. DINI:    ld    cl,#19        ;(13) delete file
  90.     ld    dx,#DFCB    ;.DDD FCB
  91.     int    BDOS
  92.  
  93.     ld    cl,#22        ;(16) create file
  94.     ld    dx,#DFCB    ;.DDD FCB
  95.     int    BDOS
  96.  
  97.     ld    cl,#15        ;(0F) open file
  98.     ld    dx,#DFCB    ;.DDD FCB
  99.     int    BDOS
  100.  
  101.     sto    #DBUF,DPTR
  102.     stob    #0,DFCB+32
  103.     stob    #1,DOUT        ;z=no .DDD file
  104.  
  105. OPFI:    ld    dx,#TFCB
  106.     ld    cl,#15        ;(0F) open file
  107.     int    BDOS
  108.     inc    al
  109.     jnz    YOPE
  110.     ld    bx,#NFIL
  111.     call    MSSG
  112.     jmp    EXIT
  113.  
  114. YOPE:    stob    #0,TFCB+32    ;set record number to zero
  115.     ld    cx,#0000    ;byte counter, kept in BC
  116.  
  117. LOOP:    call    RDSK
  118.     or    al,al
  119.     jnz    CLOS
  120.     call    WBUF
  121.     call    BREAK        ;check FOR manual interruption
  122.     ror    al
  123.     jnc    LOOP
  124.     ld    bx,#DINT
  125.     call    MSSG
  126.  
  127. ;    Clear out and close .DDD file
  128.  
  129. CLOS:    cmpb    DOUT,#0
  130.     jz    EXIT
  131. CLOA:    cmp    DPTR,#DEND
  132.     jnc    NCLR
  133.     ld    bx,DPTR
  134.     sto    #1AH,[bx]    ;^Z
  135.     inc    DPTR
  136.     ld    bx,#DFCB    ;.DDD FCB
  137.     ld    dx,#DBUF
  138. CLOB:    push    dx
  139.     push    bx
  140.     ld    cl,#26        ;(1A) set DMA address
  141.     int    BDOS
  142.     pop    dx
  143.     push    dx
  144.     ld    cl,#21        ;(15) write one record
  145.     int    BDOS
  146.     pop    bx
  147.     pop    dx
  148.     or    al,al
  149.     add    dx,#TSIZ
  150.     cmp    dx,DPTR
  151.     jc    CLOB
  152.  
  153. NCLR:    ld    cl,#16        ;(10) close file
  154.     ld    dx,#DFCB    ;.DDD FCB
  155.     int    BDOS
  156.  
  157. EXIT:    ld    dl,#00
  158.     ld    cl,#00
  159.     int    BDOS
  160.  
  161. WBUF:    ld    bx,#TBUF
  162.     call    WFOR
  163. WFOR:    call    WTWO
  164. WTWO:    call    WONE
  165. WONE:    call    WORD
  166.     call    DUBL
  167.     add    cx,#16
  168.     push    bx
  169.     call    HLIN
  170.     call    SNGL
  171.     pop    bx
  172.     call    ALIN
  173.     jmp    CRLF
  174.  
  175. ;    Type out sixteen bytes in hexadecimal representation.
  176.  
  177. HLIN:    call    HEIG
  178. HEIG:    call    HFOR
  179. HFOR:    call    HTWO
  180. HTWO:    call    HONE
  181. HONE:    ld    al,[bx]
  182.     call    BYTE
  183.     ld    al,#' '
  184.     call    CONA
  185.     inc    bx
  186.     ret
  187.  
  188. ;    Type out sixteen bytes as ASCII characters if possible.
  189.  
  190. ALIN:    call    AEIG
  191. AEIG:    call    AFOR
  192. AFOR:    call    ATWO
  193. ATWO    call    AONE
  194. AONE:    ld    al,[bx]
  195.     call    PRPR
  196.     inc    bx
  197.     ret
  198.  
  199. ;    Check whether a termination request is pending.
  200.  
  201. BREAK:    push    bx
  202.     push    dx
  203.     push    cx
  204.     ld    cl,#11        ;(0B) console status
  205.     int    BDOS
  206.     push    ax
  207.     ror    al
  208.     jnc    BRK
  209.     ld    cl,#1        ;(01) read console
  210.     int    BDOS
  211. BRK:    pop    ax
  212.     pop    cx
  213.     pop    dx
  214.     pop    bx
  215.     ret
  216.  
  217. DUBL:    call    SNGL
  218. SNGL:    ld    al,#' '
  219.     jmp    CONA
  220.  
  221. ;    Subroutines for various output formats.
  222.  
  223. CRLF:    ld    al,#CR
  224.     call    CONA
  225.     ld    al,#LF
  226.     jmp    CONA
  227.  
  228. WORD:    mov    al,ch
  229.     call    BYTE
  230.     mov    al,cl
  231. BYTE:    push    ax
  232.     ror    al
  233.     ror    al
  234.     ror    al
  235.     ror    al
  236.     call    NIBL
  237.     pop    ax
  238. NIBL:    and    al,#0FH
  239.     add    al,#90H
  240.     daa
  241.     adc    al,#40H
  242.     daa
  243. CONA:    push    bx
  244.     push    dx
  245.     push    cx
  246.     push    ax
  247.     ld    cl,#2        ;(02) char to console
  248.     mov    dl,al
  249.     int    BDOS
  250.     pop    ax
  251.     cmpb    DOUT,#0
  252.     jz    CONB
  253.     call    DDDA
  254. CONB:    pop    cx
  255.     pop    dx
  256.     pop    bx
  257.     ret
  258.  
  259. ;    Print printables, put dot for the rest.
  260.  
  261. PRPR:    cmp    al,#07FH    ;rubout
  262.     jnc    PRDO
  263.     cmp    al,#' '
  264.     jnc    CONA
  265. PRDO:    ld    al,#'.'
  266.     jmp    CONA
  267.  
  268. ;    Deposit byte in .DDD buffer and flush when full.
  269.  
  270. DDDA:    cmp    DPTR,#DEND
  271.     jc    DDDB
  272.     ld    bx,#DFCB    ;.DDD FCB
  273.     ld    dx,#DBUF
  274.     push    ax
  275. DDDC:    push    dx
  276.     push    bx
  277.     ld    cl,#26        ;(1A) set DMA address
  278.     int    BDOS
  279.     pop    dx
  280.     push    dx
  281.     ld    cl,#21        ;(15) write one record
  282.     int    BDOS
  283.     pop    bx
  284.     pop    dx
  285.     or    al,al
  286.     add    dx,#TSIZ
  287.     cmp    dx,#DEND
  288.     jc    DDDC
  289.     sto    #DBUF,DPTR
  290.     pop    ax
  291. DDDB:    ld    bx,DPTR
  292.     sto    al,[bx]
  293.     inc    DPTR
  294.     ret
  295.  
  296. ;    Memory to the console, replacing CP/M function 9, which
  297. ;    terminates messages with $. MSSG uses 00's.
  298.  
  299. MSSG:    ld    dl,[bx]
  300.     inc    bx
  301.     push    bx
  302.     ld    cl,#2
  303.     int    BDOS
  304.     pop    bx
  305.     cmpb    [bx],#00
  306.     jnz    mssg
  307.     ret
  308.  
  309. ;    Read a record from disk to be analyzed.
  310.  
  311. RDSK:    push    bx
  312.     push    dx
  313.     push    cx
  314.  
  315.     ld    cl,#26        ;(1A) set DMA address
  316.     ld    dx,#TBUF
  317.     int    BDOS
  318.  
  319.     ld    cl,#20        ;(14) read one record
  320.     ld    dx,#TFCB
  321.     int    BDOS
  322.  
  323.     pop    cx
  324.     pop    dx
  325.     pop    bx
  326.     ret
  327.  
  328. ;    -----------------------------------------------------------
  329.  
  330. NFIL:    db    CR,LF,'Requested file not present.',00
  331. SAME:    db    CR,LF,'Same file specified for source and listing.',00
  332. DINT:    db    'Dump interrupted.',00
  333. LOGO:    db    CR,LF,'File Dump/ICUAP/November 15, 1983.',CR,LF,CR,LF
  334.     db    '    DUMMP [D:]FILE[.EXT] [[D:]LIST.DDD]',CR,LF,CR,LF
  335.     db    'will allow viewing of FILE on the console; the display',CR,LF
  336.     db    'may be saved in the file LIST if one is specified. If',CR,LF
  337.     db    '.EXT is not given, .CMD is assumed.',CR,LF
  338.     db    00
  339. DOUT:    ds    1    ;z=no .DDD file
  340. DFCB:    db    'DFilenameDDD',00,00,00,00
  341.     ds    17
  342. DPTR:    ds    2
  343. DBUF:    ds    DSIZ
  344. DEND:    equ    DBUF+DSIZ
  345.  
  346.     end
  347.  
  348.