home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / c128 / text / examples.arc / DUMP.A < prev    next >
Encoding:
Text File  |  1989-12-01  |  5.9 KB  |  161 lines

  1. ; dump.asm
  2. ;============================================
  3. ; Command:  dump [[d:]filename]
  4. ;============================================
  5. ; Dumps the assembler's symbol table.
  6. ; Dump with filespec dumps to the named file.
  7. ; Otherwise dump is to the screen.
  8. ;
  9. ; Must be done immediately after running ASM
  10.  
  11.                                   
  12. shift       = $00d3               
  13. stkey       = $0091               
  14. fnadr       = $00bb               
  15. fnlen       = $00b7               
  16. index1      = $0024               
  17. stkey       = $0091               
  18. shift       = $00d3               
  19. int04       = $1704               
  20. int0d       = $170d               
  21. int0e       = $170e               
  22. int13       = $1713               
  23. int09       = $1709               
  24. primm       = $ff7d               
  25. chrout      = $ffd2               
  26. chkout      = $ffc9               
  27. clrchn      = $ffcc               
  28.                                   
  29. star        = $0b00               
  30.             .wor star             
  31.             * = star              
  32.  
  33.             jmp dump
  34.             dw Date
  35.                       
  36. dump        ldx #1                ; check if there's a %1
  37.             jsr int04             ; get char
  38.             bcs loop              ; no parameters...use screen
  39.             jsr int13             ; scratch destination
  40.             ldx #1                
  41.             lda #"s"              ; and re-open for write
  42.             jsr int09             ; open %1 as seq file
  43.             bcc noerr             ; open went ok
  44. derr        jsr clrchn            
  45.             jsr primm             
  46.             .asc 13,"Disk error: ", 0
  47.             jsr int0d             
  48.             jmp int0e             
  49.                                   
  50. noerr       jsr chkout            
  51.             bcs derr              
  52. loop        lda #>$4000           ; symbol table start
  53.             sta index1+1          
  54.             lda #<$4000           
  55.             sta index1            
  56.             jmp dump6             ; check if done & loop
  57.                                   
  58. dump3       ldy #0                ; print 6 char label
  59. dump4       jsr peek              
  60.             and #$7f              
  61.             jsr chrout            
  62.             iny                   
  63.             cpy #6                
  64.             bne dump4             
  65.             ldy #3                
  66. dump5       lda eqwls,y           ; print " = $"
  67.             jsr chrout            
  68.             dey                   
  69.             bpl dump5             
  70.             ldy #6                
  71.             jsr peek              ; address hi
  72.             jsr hexa              
  73.             iny                   
  74.             jsr peek              ; address lo
  75.             jsr hexa              
  76.                                   
  77. ;check 1st char of name. Bit 7 flags whether or not it has
  78. ;ever been used other than when it was defined.
  79.                                   
  80.             ldy #0                
  81.             jsr peek              
  82.             bmi used              
  83.             lda #" "              
  84.             jsr chrout            
  85.             lda #"                ; "                ;flag useless labels
  86.             jsr chrout            
  87.                                   
  88. used        clc                   ; bump to next label
  89.             lda #$08              
  90.             adc index1            
  91.             sta index1            
  92.             bcc used0             
  93.             inc index1+1          
  94. used0       lda #13               
  95.             jsr chrout            
  96. chkshf      lda shift             ; pause on shift
  97.             bne chkshf            
  98.             lda stkey             ; check stop
  99.             cmp #127              
  100.             beq dumpx             ; yes then done
  101.                                   
  102. ; check for a null in the label
  103. ; name. if so end of table has
  104. ; has been reached
  105.                                   
  106. dump6       ldy #5                
  107. dump06      jsr peek              
  108.             beq dumpx             
  109.             dey                   
  110.             bpl dump06            
  111.             bmi dump3             
  112.                                   
  113. dumpx       jsr clrchn            ; clear channel
  114.             jmp int0e             
  115.                                   
  116. eqwls       .byt "$ = "           
  117.                                   
  118. ;=================================
  119. ;hexout - outputs .x (lo) .y (hi)
  120. ;         as an ascii hex word.
  121. ;hexa   - outputs .a only as hex
  122. ;=================================
  123.                                   
  124. hexout      txa                   ; save lo byt
  125.             pha                   
  126.             tya                   ; do hi byt
  127.             jsr hexa              
  128.             pla                   ; now lo byte
  129. hexa        pha                   ; output .a as hex
  130.             lsr a                 
  131.             lsr a                 
  132.             lsr a                 
  133.             lsr a                 
  134.             jsr hx1               
  135.             tax                   
  136.             pla                   
  137.             and #$0f              
  138.             jsr hx1               
  139. prtxa       pha                   
  140.             txa                   
  141.             jsr chrout            
  142.             pla                   
  143.             jmp chrout            
  144.                                   
  145. hx1         clc                   
  146.             adc #$f6              
  147.             bcc hx2               
  148.             adc #$06              
  149. hx2         adc #$3a              
  150.             rts                   
  151.                                   
  152. peek        sta $ff01             
  153.             lda (index1),y        
  154.             pha                   
  155.             lda #0                
  156.             sta $ff00             
  157.             pla                   
  158.             rts                   
  159.                                   
  160.             .end                  
  161.