1: i=r3 2: .globl lptr,rptr,sptr 3: .globl succ,fail 4: .globl iget 5: .globl find,enter 6: .globl seekchar,getword,getchar 7: .globl putword,putchar,alterword 8: .globl getcstr,rewcstr 9: .globl length,rewind 10: 11: index=0 12: tablep=2 13: temp=4 14: which=6 15: framel=10 16: 17: find: 18: mov pc,-(sp) /which(sp) 19: br 1f 20: enter: 21: clr -(sp) 22: 1: 23: jsr pc,rewcstr 24: jsr pc,getcstr 25: bne 1f 26: tst (sp)+ 27: jmp fail 28: 1: 29: clr -(sp) /temp(sp) 30: jsr pc,iget 31: mov (r0),-(sp) /tablep(sp) 32: clr -(sp) /index(sp) 33: 34: right: 35: add $rptr,index(sp) 36: br 1f 37: left: 38: add $lptr,index(sp) 39: 1: /get index of next entry 40: mov tablep(sp),r1 41: mov index(sp),r0 42: jsr pc,seekchar 43: jsr pc,getword 44: tst r0 45: beq nomore 46: mov r0,index(sp) 47: add $sptr,r0 48: jsr pc,seekchar 49: jsr pc,rewcstr 50: 1: /comparison loop 51: mov tablep(sp),r1 52: jsr pc,getchar 53: mov r0,-(sp) 54: jsr pc,getcstr 55: cmp r0,(sp)+ 56: bgt right 57: blt left 58: tst r0 59: beq found 60: br 1b 61: 62: nomore: /not in table 63: tst which(sp) 64: beq 1f 65: tst (i)+ /exit from find 66: add $framel,sp 67: jmp fail 68: 1: 69: mov tablep(sp),r1 70: jsr pc,length 71: mov r0,temp(sp) 72: clr r0 73: jsr pc,putword /scratch word 74: jsr pc,putword /left pointer 75: jsr pc,putword /right 76: mov index(sp),r0 77: jsr pc,seekchar 78: mov temp(sp),r0 79: mov r0,index(sp) 80: jsr pc,alterword 81: jsr pc,rewcstr 82: 1: /copy loop 83: jsr pc,getcstr 84: mov tablep(sp),r1 85: jsr pc,putchar 86: tst r0 87: bne 1b 88: 89: found: 90: jsr pc,iget 91: mov index(sp),(r0) 92: add $framel,sp 93: jmp succ