home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / test / pdp11 / krtdeb.mac < prev    next >
Text File  |  1996-10-17  |  11KB  |  427 lines

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