1: .globl plausible 2: .globl lookchar 3: .globl wc 4: .globl seekchar 5: .globl putchar 6: .globl allocate 7: .globl release 8: .globl stats 9: .globl w,r,a,l 10: .globl bufchar 11: .globl copy 12: .globl getbuf 13: .globl swap 14: .globl fixct 15: / 16: / routine to copy the contents of one string 17: / to another. 18: / 19: / mov source,r0 20: / mov dest,r1 21: / jsr pc,copy 22: / mov r1,... 23: / 24: / on return, r1 points to the new string and should 25: / be saved. r0 is preserved. 26: / 27: copy: 28: mov r0,-(sp) 29: mov r2,-(sp) 30: mov r3,-(sp) 31: jsr pc,wc 32: 1: jsr pc,reset 33: mov w(r0),r2 34: sub a(r0),r2 /W-A 35: mov l(r1),r3 36: sub a(r1),r3 /L-A 37: cmp r2,r3 38: ble 1f 39: jsr pc,release 40: mov r2,r0 41: jsr pc,allocate 42: mov 4(sp),r0 43: / 44: 1: mov a(r1),w(r1) /rewind w pointer 45: mov a(r0),-(sp) 46: / 47: 4: mov (sp),0f 48: mov afi,r0 49: sys seek;0:.. ;0 /set input pointer 50: cmp r2,$512. 51: ble 2f 52: mov $512.,r3 /# output this time 53: mov r3,0f 54: mov r3,3f 55: add r3,(sp) 56: sub r3,r2 /# left to output 57: br 1f 58: / 59: 2: mov r2,0f 60: mov r2,3f 61: mov r2,r3 62: clr r2 63: / 64: 1: mov afi,r0 65: sys read;b1;0:.. 66: bes bad 67: cmp r0,r3 68: bne bad 69: mov afout,r0 70: mov (r1),0f 71: add r3,(r1) 72: sys seek;0:.. ;0 73: sys write;b1;3:.. 74: bes bad 75: tst r2 76: bgt 4b 77: tst (sp)+ 78: mov 4(sp),r0 /restore r0 79: / 80: / fix up read ptr of new string 81: / 82: 1: mov r(r0),r2 83: sub a(r0),r2 84: add a(r1),r2 85: mov r2,r(r1) 86: / 87: / restore and return 88: / 89: mov (sp)+,r3 90: mov (sp)+,r2 91: mov (sp)+,r0 92: rts pc 93: / 94: bad: mov $1,r0 95: sys write;1f;2f-1f 96: 4 97: 1: <error on copy\n> 98: 2: .even 99: / 100: / 101: wc: 102: mov r1,-(sp) 103: mov r2,-(sp) 104: mov r3,-(sp) 105: clr r3 106: 1: 107: cmp r3,nbuf 108: bge 1f 109: mov r3,r2 110: asl r2 111: tst w1(r2) 112: ble 2f 113: mov r3,r1 114: ashc $9.,r1 115: bic $777,r1 116: add $b1,r1 117: jsr pc,clean 118: 2: 119: inc r3 120: br 1b 121: 1: 122: jsr pc,whead 123: mov (sp)+,r3 124: mov (sp)+,r2 125: mov (sp)+,r1 126: rts pc 127: swap: 128: mov w(r1),-(sp) 129: mov w(r0),w(r1) 130: mov (sp),w(r0) 131: mov r(r1),(sp) 132: 133: mov r(r0),r(r1) 134: mov (sp),r(r0) 135: mov a(r1),(sp) 136: mov a(r0),a(r1) 137: mov (sp),a(r0) 138: mov l(r1),(sp) 139: mov l(r0),l(r1) 140: mov (sp)+,l(r0) 141: rts pc 142: / 143: / 144: / 145: / 146: / 147: / mov position,r0 148: / mov ...,r1 149: / jsr pc,seekchar 150: / 151: seekchar: 152: mov r1,-(sp) 153: mov r0,-(sp) 154: 1: 155: mov (sp),r0 156: add a(r1),r0 157: cmp r0,l(r1) 158: bhi 3f 159: mov r0,r(r1) 160: cmp r0,w(r1) 161: blo 1f 162: mov r0,w(r1) 163: br 1f 164: 3: 165: mov (sp),r0 166: jsr pc,allocate 167: mov 2(sp),r0 168: jsr pc,copy 169: jsr pc,swap 170: jsr pc,release 171: mov 2(sp),r1 172: br 1b 173: 1: 174: mov (sp)+,r0 175: mov (sp)+,r1 176: rts pc 177: / 178: reset: 179: mov r3,-(sp) 180: mov r2,-(sp) 181: clr r3 182: 1: 183: cmp r3,nbuf 184: bge 1f 185: mov r3,r2 186: asl r2 187: mov $-1.,w1(r2) 188: clr b1s(r2) 189: clr b1e(r2) 190: clr u1(r2) 191: inc r3 192: br 1b 193: 1: 194: clr flag 195: mov (sp)+,r2 196: mov (sp)+,r3 197: rts pc 198: /