home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krtdeb.mac < prev    next >
Text File  |  2020-01-01  |  10KB  |  374 lines

  1.     .title    KRTDEB    Examine data in memory
  2.     .ident    "V03.63"
  3.  
  4. ; /63/    27-Sep-97  Billy Youdelman  V03.63
  5.  
  6. ; /62/    27-Jul-93  Billy Youdelman  V03.62
  7. ;
  8. ;    use erbfsiz to size errtxt buffer
  9.  
  10. ; /BBS/     1-Dec-91  Billy Youdelman  V03.61
  11. ;
  12. ;    added new variables to data displayable with EXAMINE
  13. ;    display ascii chars when dumping byte values
  14. ;    fixed error handling
  15. ;    fixed addressing bug in pint (displays word values)
  16.  
  17. ;    Copyright 1984 Change Software, Inc.
  18. ;
  19. ;    21-May-84  22:07:50  Brian Nelson
  20.  
  21.  
  22.     .include "IN:KRTMAC.MAC"
  23.     .iif ndf  KRTINC  .error    <; .include for IN:KRTMAC.MAC failed>
  24.  
  25.  
  26.     CHR    =    1        ; string (byte) data
  27.     INT    =    2        ; integer (word) data
  28.  
  29.     .macro    entry    name ,type ,size
  30.     .save
  31.     .if  b    <name>
  32.     .psect    $addr
  33.     .word    0
  34.     .iff
  35.     .dsabl    lc
  36.     .psect    $name    ,ro,d,lcl,rel,con
  37.     $$ = .
  38.     .asciz    #name#
  39.     .psect    $addr
  40.     .word    $$
  41.     .psect    $addr1
  42.     .word    name
  43.     .psect    $type
  44.     .word    type
  45.     .psect    $size
  46.     .word    size
  47.     .enabl    lc
  48.     .endc
  49.     .restore
  50.     .endm    entry
  51.  
  52.  
  53.     .sbttl    Local data            ; /63/ consolidated here..
  54.  
  55.     .psect    $pdata
  56. deb.01:    .word    pbyte ,pint
  57. deb.02:    .word    deb.03 ,deb.04
  58. deb.03:    .asciz    <tab>"Byte data, size"    ; /BBS/ added tabs
  59. deb.04:    .asciz    <tab>"Word data, size"
  60. deb.05:    .asciz    <tab>"  Starting address: "
  61. deb.06:    .asciz    "?KRTDEB-E-"            ; /62/
  62. deb.07:    .asciz    "Symbol not in internal STB"    ; /62/
  63. deb.08:    .asciz    "Bad octal value"        ; /62/
  64. deb.09:    .asciz    ". ("            ; /BBS/ added decimal point
  65. deb.10:    .asciz    ")   "            ; /BBS/ added spaces for formatting
  66. octpad:    .asciz    "    "            ; /BBS/ dummy octal number element
  67.     .even
  68.  
  69.     .psect    $rwdata    ,rw,d,lcl,rel,con
  70. togo:    .word    0            ; /BBS/ number of bytes
  71. ascbuf:    .blkb    24            ; /BBS/ ascii buffer for byte dump
  72.     .even
  73.  
  74.  
  75.     .sbttl    Symbol name data table
  76.  
  77.     .psect    $addr    ,ro,d,lcl,rel,con
  78. texadr:
  79.     .psect    $addr1    ,ro,d,lcl,rel,con
  80. virtad:
  81.     .psect    $type    ,ro,d,lcl,rel,con
  82. symtyp:
  83.     .psect    $size    ,ro,d,lcl,rel,con
  84. symsiz:
  85.     .psect    $code
  86.  
  87.     entry    <$image>, int, 1
  88.     entry    <$limit>, int, 2
  89.     entry    <albuff>, int, 1
  90.     entry    <argbuf>, int, 1
  91.     entry    <argpnt>, int, 1
  92.     entry    <asname>, chr, ln$max
  93.     entry    <at$len>, int, 1
  94.     entry    <at$sys>, chr, 2
  95.     entry    <b4speed>,int, 1
  96.     entry    <blknum>, int, 5
  97.     entry    <buflst>, int, 5
  98.     entry    <bufp>,   int, 5
  99.     entry    <bufs>,   int, 5
  100.     entry    <cc$max>, int, 1
  101.     entry    <chksiz>, int, 1
  102.     entry    <chktyp>, chr, 1
  103.     entry    <cl$line>,int, 1
  104.     entry    <cl.line>,int, 1
  105.     entry    <cl.pri>, int, 1
  106.     entry    <cl.r50>, int, 4
  107.     entry    <cl.unit>,int, 1
  108.     entry    <clkflg>, int, 1
  109.     entry    <cmdbuf>, int, 1
  110.     entry    <conpar>, chr, 20
  111.     entry    <context>,int, 1
  112.     entry    <date.a>, int, 5
  113.     entry    <do8bit>, int, 1
  114.     entry    <doattr>, int, 1
  115.     entry    <dorpt> , int, 1
  116. ;    entry    <doslid>, int, 1
  117.     entry    <edists>, int, 1
  118.     entry    <ebquot>, chr, 1
  119.     entry    <errtxt>, chr, erbfsiz
  120.     entry    <fetpt>,  int, 1
  121.     entry    <fetptm>, int, 1
  122.     entry    <filnam>, chr, ln$max
  123.     entry    <filtyp>, int, 5
  124.     entry    <freept>, int, 1
  125.     entry    <hilimit>,int, 1
  126.     entry    <image>,  int, 1
  127.     entry    <imgtyp>, int, 1
  128.     entry    <index>,  int, 1
  129.     entry    <indnam>, chr, 16+2    ; /63/
  130.     entry    <ininam>, chr, 16+2    ; /63/
  131.     entry    <jobsts>, int, 10
  132.     entry    <jobtyp>, int, 1
  133.     entry    <km.lock>,int, 1
  134.     entry    <limits>, chr, 34.
  135.     entry    <linksts>,int, 1
  136.     entry    <logfil>, chr, 26+2    ; /63/
  137.     entry    <lokdate>,int, 1
  138.     entry    <loklen>, int, 1
  139.     entry    <lokstat>,int, 1
  140.     entry    <loktime>,int, 1
  141.     entry    <maxtop>, int, 1
  142.     entry    <mcrcmd>, int, 1
  143.     entry    <mode>,   int, 5
  144.     entry    <modtype>,int, 1
  145.     entry    <montyp>, int, 1
  146.     entry    <mready>, int, 1
  147.     entry    <numtry>, int, 1
  148.     entry    <outlun>, int, 1
  149.     entry    <outopn>, int, 1
  150.     entry    <packet>, chr, $allsiz    ; /BBS/
  151.     entry    <paknum>, int, 1
  152.     entry    <pcnt.r>, int, 2*34
  153.     entry    <pcnt.s>, int, 2*34
  154.     entry    <pnhead>, int, 1
  155.     entry    <prexon>, int, 1
  156.     entry    <prot.a>, int, 5
  157.     entry    <qedtst>, int, 1    ; /63/
  158.     entry    <qu.ini>, int, 1
  159.     entry    <r50dev>, int, 4
  160.     entry    <r50out>, int, 4    ; /63/
  161.     entry    <remote>, int, 1
  162.     entry    <restof>, int, 1
  163.     entry    <rptlast>,chr, 2    ; /63/
  164.     entry    <rptquo>, chr, 2    ; /63/
  165.     entry    <rptsave>,chr, 2    ; /63/
  166.     entry    <rt11upd>,int, 1
  167.     entry    <rt11ver>,int, 1
  168.     entry    <rtwork>, int, 10
  169.     entry    <senwin>, int, 1
  170.     entry    <senpar>, chr, 20
  171.     entry    <size>,   int, 1
  172.     entry    <sizof>,  int, 5
  173.     entry    <snd8bit>,int, 1
  174.     entry    <spare1>, chr, 256.
  175.     entry    <sparsz>, int, 1
  176.     entry    <srcnam>, chr, ln$max
  177.     entry    <stklim>, chr, stksiz    ; /62/ dump the stack, backwards!
  178.     entry    <time.a>, int, 5
  179.     entry    <times>,  int, 10    ; /BBS/ wuz 4
  180.     entry    <totp.r>, int, 1    ; pointer
  181.     entry    <totp.s>, int, 1    ; pointer
  182.     entry    <tsxcl>,  int, 1
  183.     entry    <tsxsav>, int, 1
  184.     entry    <tsxver>, int, 1
  185.     entry    <tt$io>,  int, 1
  186.     entry    <ttbuf>,  int, ttbsiz+2
  187.     entry    <ttparm>, int, 1
  188.     entry    <ttpar2>, int, 1
  189.     entry    <undchr>, chr, 2
  190.     entry    <undlin>, chr, ln$max+2
  191.     entry    <vbgexe>, int, 1
  192.     entry    <xcdone>, int, 1
  193.     entry    <xkbuff>, chr, <xksize+2>
  194.     entry    <xklgbu>, int, 1
  195.     entry    <xkpoint>,int, 1
  196.     entry    <xl.lock>,int, 1
  197.     entry    <xmfetp>, int, 1
  198.     entry    <z.atch>, int, 1
  199.     entry
  200.  
  201.  
  202.     .sbttl    EXAMINE data in memory
  203.  
  204. c$exam::upcase    argbuf            ; /63/ more appropriate name..
  205.     cmpb    @r0    ,#'0        ; /45/ numeric?
  206.     blo    10$            ; /45/ no
  207.     cmpb    @r0    ,#'9        ; /62/ numeric?
  208.     bhi    10$            ; /45/ no
  209.     calls    octval    ,<r0>        ; /45/ yes, get the address
  210.     tst    r0            ; /BBS/ ok?
  211.     bne    50$            ; /BBS/ nope
  212.     bic    #1    ,r1        ; /62/ ensure it's word aligned
  213.  
  214. ; /BBS/ WARNING: This only works for valid addresses.
  215. ;    Consult the link map and assembly listings to
  216. ;    determine what is valid.  Attempting to access
  217. ;    an illegal address will trap to the monitor.
  218.  
  219.     octout    @r1            ; /45/ dump the data
  220.     br    60$            ; /45/ exit
  221.  
  222. 10$:    cmpb    @r0    ,#'*        ; dump everything today?
  223.     bne    30$            ; no
  224.     clr    r0            ; yes, start with first one
  225. 20$:    tst    texadr(r0)        ; keep going until address of zero
  226.     beq    70$            ; exit /BBS/ skip extra newline at end
  227.     call    prtsym            ; print the symbol out
  228.     add    #2    ,r0        ; next please
  229.     .newline
  230.     br    20$
  231.  
  232. 30$:    call    findsy            ; find the symbol now
  233.     tst    r0            ; found it?
  234.     bmi    40$            ; no
  235.     call    prtsym            ; dump it please
  236.     br    60$
  237.  
  238. 40$:    wrtall    #deb.06            ; /63/ "?KRTDEB-E-"
  239.     wrtall    #deb.07            ; /63/ "Symbol not in internal STB"
  240.     br    60$
  241. 50$:    wrtall    #deb.06            ; /63/ "?KRTDEB-E-"
  242.     wrtall    #deb.08            ; /63/ "Bad octal value"
  243. 60$:    .newline
  244. 70$:    clr    r0            ; /62/
  245.     return
  246.  
  247.  
  248.     .sbttl    Print symbol
  249.  
  250. ;    input:    r0    offset
  251.  
  252. prtsym:    save    <r0>
  253.     sub    #20    ,sp        ; allocate a small text buffer
  254.     mov    sp    ,r3        ; and a pointer
  255.     mov    r0    ,r5        ; ensure we don't zap offset
  256.     wrtall    texadr(r5)        ; print the symbol name
  257.     mov    symtyp(r5),r4        ; get the class of symbol
  258.     asl    r4            ; word indexing
  259.     wrtall    deb.02-2(r4)        ; /63/ format it a bit
  260.     deccvt    symsiz(r5),r3,#5    ; get the data item's size
  261.     clrb    5(r3)            ; null terminate
  262.     wrtall    r3            ; print that out
  263.     mov    #'.    ,r0
  264.     call    writ1ch            ; /BBS/ add decimal point
  265.     wrtall    #deb.05            ; /BBS/ address header
  266.     octout    virtad(r5)        ; /BBS/ display starting address
  267.     .newline
  268.     .newline
  269.     jsr    pc    ,@deb.01-2(r4)    ; /63/ call appropriate format routine
  270.     add    #20    ,sp
  271.     unsave    <r0>
  272.     return
  273.  
  274.  
  275.     .sbttl    Format byte data
  276.  
  277. pbyte:    sub    #20    ,sp        ; a buffer to use today
  278.     mov    symsiz(r5),togo        ; number of bytes to dump
  279.     beq    90$            ; nothing to do..
  280.     mov    virtad(r5),r5        ; get the base address
  281. 10$:    mov    #20    ,r3        ; maximum of 16 items per line
  282.     mov    #ascbuf    ,r1        ; /BBS/ for ascii display of line
  283. 20$:    mov    sp    ,r2        ; pointer to local buffer
  284.     clr    r4            ; get the next byte please
  285.     bisb    (r5)+    ,r4        ; without sign extension
  286.     clrb    (r1)            ; /BBS/ prep to ..
  287.     bisb    r4    ,(r1)        ; /BBS/ ..copy sans sign extension
  288.     bicb    #^c<177>,(r1)        ; /BBS/ hose hi bit
  289.     cmpb    (r1)    ,#space        ; /BBS/ printable?
  290.     blt    30$            ; /BBS/ no
  291.     cmpb    (r1)    ,#177        ; /BBS printable?
  292.     blt    40$            ; /BBS/ ya
  293. 30$:    movb    #'.&77    ,(r1)+        ; /BBS/ no, stuff a dot
  294.     br    50$            ; /BBS/ and continue
  295. 40$:    tstb    (r1)+            ; /BBS/ save char, bump to next byte
  296. 50$:    mov    r4    ,r0        ; copy it
  297.     ash    #-6    ,r0        ; get the high two bits now
  298.     bic    #^c<3>    ,r0        ; mask the lower bits please
  299.     add    #'0    ,r0        ; convert
  300.     movb    r0    ,(r2)+        ; and copy
  301.     mov    r4    ,r0        ; copy it
  302.     ash    #-3    ,r0        ; get the high two bits now
  303.     bic    #^c<7>    ,r0        ; mask the lower bits please
  304.     add    #'0    ,r0        ; convert
  305.     movb    r0    ,(r2)+        ; and copy
  306.     mov    r4    ,r0        ; copy it
  307.     bic    #^c<7>    ,r0        ; mask the lower bits please
  308.     add    #'0    ,r0        ; convert
  309.     movb    r0    ,(r2)+        ; and copy
  310.     movb    #space    ,(r2)+        ; /BBS/ a trailing space
  311.     clrb    @r2            ; at last, .asciz
  312.     mov    sp    ,r2        ; restore buffer pointer and print
  313.     wrtall    r2            ; simple
  314.     dec    togo            ; anything else to print
  315.     beq    60$            ; no
  316.     sob    r3    ,20$        ; yes, next on the line please
  317.     call    100$            ; /BBS/ dump ascii list next then goto
  318.     br    10$            ; next line
  319. 60$:    dec    r3            ; /BBS/ adj r3 for last pass thru loop
  320.     ble    80$            ; /BBS/ r3 now contains pad count
  321. 70$:    wrtall    #octpad            ; /BBS/ blanks where "000" would be
  322.     sob    r3    ,70$        ; /BBS/ until padded to a full line
  323. 80$:    call    100$            ; /BBS/ now dump ascii chars
  324. 90$:    add    #20    ,sp        ; release the local buffer
  325.     return
  326.  
  327. 100$:    movb    #cr    ,(r1)+        ; /BBS/ stuff a CR
  328.     movb    #lf    ,(r1)+        ; /BBS/ and LF in buffer
  329.     clrb    @r1            ; /BBS/ terminate it
  330.     wrtall    #ascbuf            ; /BBS/ dump it to screen
  331.     return
  332.  
  333.  
  334.     .sbttl    Format integer data
  335.  
  336. pint:    mov    symsiz(r5),r1        ; get the number of data elements
  337.     beq    40$            ; nothing to do at all
  338.     mov    virtad(r5),r2        ; get the address of what to print
  339. 10$:    mov    #4    ,r3        ; number of items per line
  340. 20$:    mov    (r2)+    ,r4        ; /BBS/ get word while in this segment
  341.     decout    r4            ; dump it /BBS/ wuz (r2)
  342.     wrtall    #deb.09            ; /63/ ". ("
  343.     octout    r4            ; /BBS/ (r2)+ can return BAD values!!
  344.     wrtall    #deb.10            ; /63/ ")   "
  345.     dec    r1            ; all done?
  346.     beq    30$            ; yes, exit
  347.     sob    r3    ,20$        ; not done, print next item
  348.     .newline
  349.     br    10$            ; next line of printing
  350. 30$:    .newline
  351. 40$:    return
  352.  
  353.  
  354.     .sbttl    Locate symbol offset in index
  355.  
  356. findsy:    clr    r3            ; init index
  357. 10$:    mov    texadr(r3),r1        ; point to the text now
  358.     beq    50$            ; if eq, we hit the end of it all
  359.     mov    r0    ,r2        ; /BBS/ refresh pointer
  360. 20$:    cmpb    (r2)+    ,(r1)+        ; check for exact match on characters
  361.     bne    30$            ; no
  362.     tstb    (r2)            ; ya, anything left?
  363.     bne    20$            ; ya, keep checking
  364.     br    40$            ; no, it's a match
  365. 30$:    add    #2    ,r3        ; no match, advance to the next addr
  366.     br    10$            ; next please
  367.  
  368. 40$:    mov    r3    ,r0        ; return index in r0
  369.     br    60$
  370. 50$:    mov    #-1    ,r0        ; no match, return index of -1
  371. 60$:    return
  372.  
  373.     .end
  374.