1: / ar -- archive/library 2: 3: mov (sp)+,r0 4: sub $2,r0 5: ble userr 6: tst (sp)+ 7: mov (sp)+,r1 8: clr r2 9: 1: 10: tstb (r1) 11: beq 1f 12: cmpb (r1),$'v 13: bne 2f 14: inc r1 15: incb vflg 16: br 1b 17: 2: 18: tst r2 19: bne userr 20: movb (r1)+,r2 21: br 1b 22: 1: 23: tst r2 24: beq userr 25: mov $arglst,r1 26: 1: 27: mov (sp)+,(r1)+ 28: dec r0 29: bgt 1b 30: clr (r1)+ 31: mov $swlst,r1 32: 1: 33: cmp r2,(r1)+ 34: beq 1f 35: tst (r1)+ 36: bne 1b 37: br userr 38: 1: 39: jmp *(r1) 40: 41: swlst: 42: 'r; comr 43: 'u; comu 44: 'd; comd 45: 'x; comx 46: 't; comt 47: 0; 0 48: 49: userr: 50: jsr r5,diag 51: <bad usage\n\0> 52: .even 53: 54: putc: 55: movb r0,ch 56: mov $1,r0 57: sys write; ch; 1 58: rts r5 59: 60: print: 61: movb (r1)+,r0 62: beq 1f 63: jsr r5,putc 64: br print 65: 1: 66: rts r5 67: 68: diag: 69: mov r5,r1 70: jsr r5,print 71: tst tfo 72: beq 1f 73: sys unlink; tfil 74: 1: 75: sys exit 76: 77: getaf: 78: mov arglst,0f 79: sys open; 0:..; 0 80: bes 1f 81: mov r0,afi 82: sys read; buf; 2 83: cmp buf,magic 84: bne magerr 85: tst (r5)+ 86: 1: 87: rts r5 88: 89: magerr: 90: mov arglst,r1 91: jsr r5,print 92: jsr r5,diag 93: < -- not in archive format\n\0> 94: .even 95: 96: mktmp: 97: sys stat; tfil; buf 98: bes 1f 99: incb tfil+8 100: cmpb tfil+8,$'z 101: blo mktmp 102: br tferr 103: 1: 104: sys signal; 2; 1 105: ror r0 106: bcs 1f 107: sys signal; 2; done 108: 1: 109: sys creat; tfil; 600 110: bes tferr 111: mov r0,tfo 112: sys open; tfil; 0 113: bes tferr 114: mov r0,tfi 115: rts r5 116: 117: tferr: 118: jsr r5,diag 119: <cannot open temp file\n\0> 120: .even 121: 122: getdir: 123: mov afi,r0 124: sys read; dir; 16. 125: cmp r0,$16. 126: bne 1f 127: jsr r5,mvname 128: tst (r5)+ 129: 1: 130: rts r5 131: 132: mvname: 133: mov name,rname 134: mov name+2,rname+2 135: mov name+4,rname+4 136: mov name+6,rname+6 137: rts r5 138: 139: skip: 140: mov size,r0 141: inc r0 142: bic $1,r0 143: mov r0,0f 144: mov afi,r0 145: sys seek; 0:..; 1 146: rts r5 147: 148: trim: 149: mov r0,r2 150: 1: 151: tstb (r0) 152: beq 1f 153: cmpb (r0)+,$'/ 154: beq trim 155: br 1b 156: 1: 157: rts r5 158: 159: match: 160: mov $arglst+2,r1 161: 1: 162: mov (r1)+,r0 163: beq 1f 164: cmp r0,$-1 165: beq 1b 166: jsr r5,trim 167: mov $name,r0 168: 2: 169: cmp r0,$name+8. 170: beq 2f 171: cmpb (r0),(r2)+ 172: bne 1b 173: tstb (r0)+ 174: bne 2b 175: 2: 176: cmp (r5)+,-(r1) 177: 1: 178: rts r5 179: 180: mvfil: 181: mov (r1),9f 182: mov (r1),0f 183: sys stat; 0:..; buf 184: bes operr 185: sys open; 9:..; 0 186: bes operr 187: mov r0,fio 188: mov (r1),r0 189: mov $-1,(r1) 190: jsr r5,trim 191: mov $name,r0 192: 1: 193: cmp r0,$name+8. 194: beq 1f 195: movb (r2)+,(r0)+ 196: bne 1b 197: 1: 198: mov buf+32.,mtim 199: mov buf+34.,mtim+2 200: movb buf+7.,ouid 201: movb buf+4.,mode 202: mov buf+10.,size 203: mov tfo,r0 204: sys write; dir; 16. 205: mov size,r2 206: 1: 207: mov fio,r0 208: sys read; buf; 512. 209: sub r0,r2 210: mov r0,0f 211: beq 1f 212: mov tfo,r0 213: sys write; buf; 0:.. 214: br 1b 215: 1: 216: tst r2 217: bne phserr 218: bit $1,size 219: beq 1f 220: mov tfo,r0 221: sys seek; 1; 1 222: 1: 223: mov fio,r0 224: sys close 225: jsr r5,mvname 226: rts r5 227: 228: operr: 229: mov 9b,r1 230: jsr r5,print 231: jsr r5,diag 232: < -- cannot open\n\0> 233: .even 234: 235: phserr: 236: mov 9b,r1 237: jsr r5,print 238: jsr r5,diag 239: < -- phase error\n\0> 240: .even 241: 242: copyfl: 243: mov tfo,r0 244: sys write; dir; 16. 245: mov size,r1 246: mov $rname,9b 247: 1: 248: mov r1,0f 249: beq 1f 250: cmp r1,$512. 251: blo 2f 252: mov $512.,0f 253: 2: 254: mov afi,r0 255: sys read; buf; 0:.. 256: sub r0,r1 257: mov r0,0f 258: beq phserr 259: mov tfo,r0 260: sys write; buf; 0:.. 261: br 1b 262: 1: 263: bit $1,size 264: beq 1f 265: mov afi,r0 266: sys seek; 1; 1 267: mov tfo,r0 268: sys seek; 1; 1 269: 1: 270: rts r5 271: 272: xtract: 273: / movb mode,0f 274: sys creat; rname; 0:666 275: bes noxerr 276: mov r0,fio 277: mov size,r1 278: mov $rname,9b 279: 1: 280: mov r1,0f 281: beq 1f 282: cmp r1,$512. 283: blo 2f 284: mov $512.,0f 285: 2: 286: mov afi,r0 287: sys read; buf; 0:.. 288: sub r0,r1 289: mov r0,0f 290: beq phserr 291: mov fio,r0 292: sys write; buf; 0:.. 293: br 1b 294: 1: 295: mov fio,r0 296: sys close 297: bit $1,size 298: beq 1f 299: mov afi,r0 300: sys seek; 1; 1 301: 1: 302: mov r0,-(sp) 303: mov r1,-(sp) 304: mov mtim+2,r1 305: mov mtim,r0 306: / sys mdate 307: mov (sp)+,r1 308: mov (sp)+,r1 309: rts r5 310: 311: noxerr: 312: mov $rname,r1 313: jsr r5,print 314: jsr r5,diag 315: < -- cannot create\n\0> 316: .even 317: 318: table: 319: mov $rname,r1 320: jsr r5,print 321: mov $'\n,r0 322: jsr r5,putc 323: rts r5 324: 325: mesg: 326: mov r1,-(sp) 327: mov (r5)+,r0 328: tstb vflg 329: beq 1f 330: jsr r5,putc 331: mov $' ,r0 332: jsr r5,putc 333: mov $rname,r1 334: jsr r5,print 335: mov $'\n,r0 336: jsr r5,putc 337: 1: 338: mov (sp)+,r1 339: rts r5 340: 341: oldnew: 342: sys stat; rname; buf 343: bes 1f 344: cmp buf+32.,mtim 345: blo 1f 346: bhi 2f 347: cmp buf+34.,mtim+2 348: blos 1f 349: 2: 350: tst (r5)+ 351: mov $rname,tname 352: mov $tname,r1 353: 1: 354: rts r5 355: 356: comr: 357: jsr r5,mktmp 358: jsr r5,getaf 359: br copfl 360: 1: 361: jsr r5,getdir 362: br copfl 363: jsr r5,match 364: br 2f 365: jsr r5,mesg; 'r 366: jsr r5,skip 367: jsr r5,mvfil 368: br 1b 369: 2: 370: jsr r5,copyfl 371: jsr r5,mesg; 'c 372: br 1b 373: 374: comu: 375: jsr r5,mktmp 376: jsr r5,getaf 377: br noaf 378: 1: 379: jsr r5,getdir 380: br copfl 381: tst arglst+2 382: beq 2f 383: jsr r5,match 384: br 3f 385: mov $-1,(r1) 386: 2: 387: jsr r5,oldnew 388: br 3f 389: jsr r5,mesg; 'r 390: jsr r5,skip 391: jsr r5,mvfil 392: br 1b 393: 3: 394: jsr r5,copyfl 395: jsr r5,mesg; 'c 396: br 1b 397: 398: comd: 399: jsr r5,mktmp 400: jsr r5,getaf 401: br noaf 402: 1: 403: jsr r5,getdir 404: br 1f 405: jsr r5,match 406: br 2f 407: mov $-1,(r1) 408: jsr r5,skip 409: jsr r5,mesg; 'd 410: br 1b 411: 2: 412: jsr r5,copyfl 413: jsr r5,mesg; 'c 414: br 1b 415: 1: 416: jsr r5,nfound 417: br copfl 418: 419: noaf: 420: jsr r5,diag 421: <no archive file\n\0> 422: .even 423: 424: crterr: 425: jsr r5,diag 426: <cannot create archive file\n\0> 427: .even 428: 429: copfl: 430: mov $arglst,r1 431: mov (r1)+,0f 432: 1: 433: tst (r1)+ 434: beq 1f 435: cmp -2(r1),$-1 436: beq 1b 437: tst -(r1) 438: jsr r5,mvfil 439: jsr r5,mesg; 'a 440: br 1b 441: 1: 442: sys signal; 2; 1 / no interrupts during copy back 443: sys creat; 0:..; 666 444: bes crterr 445: mov r0,afo 446: sys write; magic; 2 447: 1: 448: mov tfi,r0 449: sys read; buf; 512. 450: mov r0,0f 451: beq done 452: mov afo,r0 453: sys write; buf; 0:.. 454: br 1b 455: 456: done: 457: jsr r5,diag 458: <\0> 459: .even 460: 461: comx: 462: jsr r5,getaf 463: br noaf 464: 1: 465: jsr r5,getdir 466: br 1f 467: tst arglst+2 468: beq 3f 469: jsr r5,match 470: br 2f 471: mov $-1,(r1) 472: 3: 473: jsr r5,xtract 474: jsr r5,mesg; 'x 475: br 1b 476: 2: 477: jsr r5,skip 478: br 1b 479: 1: 480: jsr r5,nfound 481: br done 482: 483: comt: 484: jsr r5,getaf 485: br noaf 486: 1: 487: jsr r5,getdir 488: br 1f 489: tst arglst+2 490: beq 2f 491: jsr r5,match 492: br 3f 493: mov $-1,(r1) 494: 2: 495: jsr r5,table 496: 3: 497: jsr r5,skip 498: br 1b 499: 1: 500: jsr r5,nfound 501: br done 502: 503: nfound: 504: mov $arglst+2,r2 505: 1: 506: mov (r2)+,r1 507: beq 1f 508: cmp r1,$-1 509: beq 1b 510: mov $-1,-(r2) 511: jsr r5,print 512: mov $notfnd,r1 513: jsr r5,print 514: br 1b 515: 1: 516: rts r5 517: 518: notfnd: 519: < -- not found\n\0> 520: .even 521: 522: tfil: </tmp/vtma\0> 523: .even 524: magic: -147. 525: 526: .bss 527: 528: afi: .=.+2 529: afo: .=.+2 530: tfi: .=.+2 531: tfo: .=.+2 532: fio: .=.+2 533: rname: .=.+9. 534: ch: .=.+1 535: vflg: .=.+1 536: .even 537: tname: .=.+2 538: dir: 539: name: .=.+8. 540: mtim: .=.+4 541: ouid: .=.+1 542: mode: .=.+1 543: size: .=.+2 544: arglst: .=.+200. 545: buf: .=.+512.