home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / source / tmg / tmgb / cstr.s < prev    next >
Encoding:
Text File  |  1975-05-13  |  1.1 KB  |  76 lines

  1. .globl jget,iget
  2. .globl succ
  3. .globl create,rewind,putchar,getchar,allocate
  4. .globl smark
  5. .globl rewcstr,putcstr,getcstr,size
  6.  
  7. / currnet string manipulations
  8. / keep a initial fragment handy for quick access
  9. /go to allocator for the rest
  10.  
  11. smark:
  12.     jsr    pc,jget
  13.     clr    cstrw
  14.     jmp    succ
  15.  
  16. rewcstr:
  17.     clr    cstrr
  18.     rts    pc
  19.  
  20. putcstr:
  21.     mov    cstrw,r1
  22.     inc    cstrw
  23.     cmp    r1,$cstrt    /is it quick access?
  24.     bge    1f
  25.     movb    r0,cstrb(r1)    /yes, stash the char
  26.     rts    pc
  27. 1:
  28.     bne    1f
  29.     mov    r0,-(sp)    /first char to allocator
  30.     mov    symp,r1
  31.     bne    2f
  32.     mov    $64,r0
  33.     jsr    pc,allocate
  34.     mov    r1,symp
  35. 2:
  36.     jsr    pc,create
  37.     mov    (sp)+,r0
  38. 1:
  39.     mov    symp,r1
  40.     jsr    pc,putchar
  41.     rts    pc
  42.  
  43. getcstr:
  44.     mov    cstrr,r1
  45.     cmp    r1,cstrw
  46.     blt    1f
  47.     clr    r0    /end of string
  48.     rts    pc
  49. 1:
  50.     inc    cstrr
  51.     cmp    r1,$cstrt
  52.     bge    1f
  53.     movb    cstrb(r1),r0
  54.     rts    pc
  55. 1:
  56.     bne    1f
  57.     mov    symp,r1
  58.     jsr    pc,rewind
  59. 1:
  60.     mov    symp,r1
  61.     jsr    pc,getchar
  62.     rts    pc
  63.  
  64. size:
  65.     jsr    pc,iget
  66.     mov    cstrw,(r0)
  67.     jmp    succ
  68.  
  69. cstrt = 16        /top of quick access current string
  70. .data
  71. symp:    0    /pointer to dynamicallly allocated current string
  72. cstrw:    0    /current string write pointer
  73. .bss
  74. cstrr:    .=.+2    /read pointer
  75. cstrb:    .=.+cstrt    /base of quick access fragment
  76.