1: .globl getchar 2: .globl stats 3: .globl lookchar 4: .globl fsfile 5: .globl seekchar 6: .globl backspace 7: .globl putchar 8: .globl alterchar 9: .globl move 10: .globl rewind 11: .globl create 12: .globl zero 13: .globl allocate 14: .globl release 15: .globl collect 16: .globl getword, putword 17: .globl length, position 18: .globl w, r, a, l 19: / 20: testing = 0 21: / 22: / 23: / routine to return the length of a string 24: / 25: / mov ...,r1 26: / jsr pc,length 27: / mov r0,... 28: / 29: length: 30: mov w(r1),r0 31: sub a(r1),r0 32: rts pc 33: / 34: / 35: / routine to return the read pointer position 36: / 37: / mov ...,r1 38: / jsr pc,position 39: / mov r0,... 40: / 41: position: 42: mov r(r1),r0 43: sub a(r1),r0 44: rts pc 45: / 46: / 47: / 48: / 49: / routine to get a word from the string 50: / mov ...,r1 51: / jsr pc,getword 52: / mov r0,... 53: / 54: getword: 55: jsr pc,getchar 56: bes noch 57: movb r0,nchar 58: jsr pc,getchar 59: bec 2f 60: dec r(r1) 61: br noch 62: 2: movb r0,nchar+1 63: mov nchar,r0 64: tst r0 /tst clears c-bit 65: rts pc 66: / 67: / 68: / routine to put a word onto the string 69: / mov ...,r1 70: / mov ...,r0 71: / jsr pc,putword 72: / 73: putword: 74: jsr pc,putchar 75: swab r0 76: jsr pc,putchar 77: swab r0 78: rts pc 79: / 80: .bss 81: nchar: .=.+2 82: .text 83: / 84: / 85: / 86: / routine to read next character from string 87: / pointed to by r1; character returned in r0 88: / c-bit set if character not available (end of file) 89: / r1 is preserved 90: / 91: / mov ...,r1 92: / jsr pc,getchar 93: / movb r0,... 94: / 95: getchar: 96: jsr pc,lookchar 97: bec 2f 98: rts pc 99: 2: inc r(r1) 100: tst r0 /tst clears c-bit 101: rts pc 102: / 103: noch: clr r0 104: sec 105: rts pc 106: / 107: / routine to look at next character from string 108: / pointed to by r1; character returned in r0 109: / c-bit set if character not available (end of file) 110: / r1 is preserved 111: / 112: / mov ...,r1 113: / jsr pc,lookchar 114: / movb r0,... 115: / 116: lookchar: 117: .if testing 118: jsr pc,plausible 119: inc stats+6. 120: .endif 121: cmp w(r1),r(r1) 122: blos noch 123: movb *r(r1),r0 124: clc 125: rts pc 126: / 127: plausible: 128: cmp r1,$headers 129: bhis 9f; 4; 9: 130: cmp r1,$headend 131: blo 9f; 4; 9: 132: rts pc 133: / 134: / 135: / 136: / routine to move the read pointer of a string to a 137: / specified point. If the string is not long enough, 138: / the string is extended 139: / 140: / mov position,r0 141: / mov ...,r1 142: / jsr pc,seekchar 143: / 144: seekchar: 145: mov r1,-(sp) 146: mov r0,-(sp) 147: .if testing 148: jsr pc,plausible 149: inc stats+10. 150: .endif 151: 1: 152: mov (sp),r0 153: add a(r1),r0 154: cmp r0,l(r1) 155: bhi 3f 156: mov r0,r(r1) 157: cmp r0,w(r1) 158: blo 1f 159: mov r0,w(r1) 160: br 1f 161: 3: 162: mov (sp),r0 163: jsr pc,allocate 164: mov 2(sp),r0 165: jsr pc,move 166: jsr pc,swap 167: jsr pc,release 168: mov 2(sp),r1 169: br 1b 170: 1: 171: mov (sp)+,r0 172: mov (sp)+,r1 173: rts pc 174: / 175: / 176: / routine to move read pointer of string to end of string 177: / 178: / mov ...,r1 179: / jsr pc,fsfile 180: / 181: fsfile: 182: .if testing 183: jsr pc,plausible 184: inc stats+10. 185: .endif 186: mov w(r1),r(r1) 187: rts pc 188: / 189: / 190: / routine to read a string backwards 191: / the read pointer is decremented before reading 192: / 193: / mov ...,r1 194: / jsr pc,backspace 195: / mov r0,... 196: / 197: backspace: 198: .if testing 199: jsr pc,plausible 200: inc stats+6. 201: .endif 202: cmp a(r1),r(r1) 203: bhis noch 204: dec r(r1) 205: movb *r(r1),r0 206: clc 207: rts pc 208: / 209: / 210: / 211: / 212: / routine to put a character into the string 213: / pointed to by r1; character in r0 214: / r0 and r1 are preserved. 215: / 216: / movb ch,r0 217: / mov ...,r1 218: / jsr pc,putchar 219: / 220: putchar: 221: mov r1,-(sp) 222: mov r0,-(sp) 223: .if testing 224: jsr pc,plausible 225: inc stats+8. 226: .endif 227: 1: cmp w(r1),l(r1) 228: blt 3f 229: mov w(r1),r0 230: inc r0 231: sub a(r1),r0 /W-A+1 232: jsr pc,allocate 233: mov 2(sp),r0 /r1 234: jsr pc,move 235: jsr pc,swap 236: jsr pc,release 237: mov 2(sp),r1 /r1 238: cmp w(r1),l(r1) 239: blt 3f 240: jmp err 241: / 242: 3: movb (sp),*w(r1) 243: inc w(r1) 244: mov (sp)+,r0 245: tst (sp)+ 246: rts pc 247: / 248: / 249: swap: 250: mov w(r1),-(sp) 251: mov w(r0),w(r1) 252: mov (sp),w(r0) 253: mov r(r1),(sp) 254: mov r(r0),r(r1) 255: mov (sp),r(r0) 256: mov a(r1),(sp) 257: mov a(r0),a(r1) 258: mov (sp),a(r0) 259: mov l(r1),(sp) 260: mov l(r0),l(r1) 261: mov (sp)+,l(r0) 262: rts pc 263: / 264: / 265: / routine to alter a character in the string 266: / pointed to by r1; character in r0 267: / r0 and r1 are preserved. 268: / 269: / movb ch,r0 270: / mov ...,r1 271: / jsr pc,alterchar 272: / 273: alterchar: 274: mov r1,-(sp) 275: mov r0,-(sp) 276: .if testing 277: jsr pc,preposterous 278: inc stats+8. 279: .endif 280: 1: cmp r(r1),l(r1) 281: blt 3f 282: mov l(r1),r0 283: inc r0 284: sub a(r1),r0 /W-A+1 285: jsr pc,allocate 286: mov 2(sp),r0 /r1 287: jsr pc,move 288: jsr pc,swap 289: jsr pc,release 290: mov 2(sp),r1 /r1 291: cmp r(r1),l(r1) 292: blt 3f 293: jmp err 294: / 295: 3: movb (sp),*r(r1) 296: inc r(r1) 297: cmp r(r1),w(r1) 298: ble 1f 299: mov r(r1),w(r1) 300: 1: 301: mov (sp)+,r0 302: tst (sp)+ 303: rts pc 304: / 305: / 306: / routine to move the contents of one string 307: / to another. 308: / 309: / mov source,r0 310: / mov dest,r1 311: / jsr pc,move 312: / 313: / on return, r1 points to the new string and should 314: / be saved. r0 is preserved. 315: / 316: move: 317: mov r3,-(sp) 318: mov r2,-(sp) 319: mov r1,-(sp) 320: mov r0,-(sp) 321: mov w(r0),r2 322: sub a(r0),r2 /W-A 323: mov l(r1),r3 324: sub a(r1),r3 /L-A 325: cmp r2,r3 326: ble 1f 327: mov r2,r0 328: jsr pc,allocate 329: mov 2(sp),r0 /r1 330: jsr pc,swap 331: jsr pc,release 332: mov r0,r1 333: mov 0(sp),r0 /r0 334: / 335: 1: mov a(r0),(r0) 336: mov a(r1),(r1) 337: 1: dec r2 338: blt 1f 339: movb *(r0),*(r1) 340: inc (r0) 341: inc (r1) 342: br 1b 343: / 344: / fix up read ptr of new string 345: / 346: 1: mov r(r0),r2 347: sub a(r0),r2 348: add a(r1),r2 349: mov r2,r(r1) 350: / 351: / restore and return 352: / 353: mov (sp)+,r0 354: mov (sp)+,r1 355: mov (sp)+,r2 356: mov (sp)+,r3 357: rts pc 358: / 359: / 360: / routine to rewind read pointer of string 361: / pointed to by r1 362: / 363: / mov ...,r1 364: / jsr pc,rewind 365: / 366: rewind: 367: .if testing 368: jsr pc,plausible 369: inc stats+10. 370: .endif 371: mov a(r1),r(r1) 372: rts pc 373: / 374: / routine to rewind write pointer of string 375: / pointed to by r1 376: / 377: / mov ...,r1 378: / jsr pc,create 379: / 380: create: 381: .if testing 382: jsr pc,plausible 383: inc stats+10. 384: .endif 385: mov a(r1),w(r1) 386: mov a(r1),r(r1) 387: rts pc 388: / 389: / 390: / routine to zero a string 391: / 392: / mov ...,r1 393: / jsr pc,zero 394: / 395: zero: 396: mov r0,-(sp) 397: .if testing 398: jsr pc,preposterous 399: .endif 400: mov a(r1),r0 401: 1: cmp r0,l(r1) 402: bhis 1f 403: clrb (r0)+ 404: br 1b 405: 1: mov (sp)+,r0 406: rts pc 407: / 408: /