1: /
   2: /
   3: ed:
   4:         mov     (sp)+,r3
   5:         ble     error
   6: econ:
   7:         sys     stat; ftemp; buffer
   8:         bec     2f
   9:         sys     creat; ftemp; 666
  10:         mov     r0,tmpw
  11:         sys     open; ftemp; 0
  12:         mov     r0,tmpr
  13:         br      1f
  14: 2:
  15:         cmpb    $'z,ftemp+9.
  16:         bne     2f
  17:         mov     $1,r0
  18:         sys     write; erm; 23.
  19:         jmp     loop
  20: 2:
  21:         incb    ftemp+9.
  22:         br      econ
  23: 1:
  24:         mov     (sp),r0
  25:         jsr     pc,getspq
  26:         bes     3f
  27:         mov     r0,r4
  28:         mov     r2,r1
  29:         jsr     pc,rewind
  30:         mov     $buffer,r2
  31: 1:
  32:         jsr     pc,getchar
  33:         bes     1f
  34:         movb    r0,(r2)+
  35:         br      1b
  36: 1:
  37:         movb    $'\n,(r2)+
  38:         jsr     pc,output
  39:         mov     r4,r1
  40:         jsr     pc,rewind
  41: 2:
  42:         mov     $buffer,r2
  43: 1:
  44:         jsr     pc,getchar
  45:         bes     1f
  46:         movb    r0,(r2)+
  47:         cmp     r2,$bufend
  48:         blo     1b
  49:         mov     tmpw,r0
  50:         sys     write; buffer; 512.
  51:         br      2b
  52: 1:
  53:         sub     $buffer,r2
  54:         beq     4f
  55:         mov     r2,0f
  56:         mov     tmpw,r0
  57:         sys     write; buffer; 0:..
  58: 4:
  59:         tst     iflag
  60:         beq     1f
  61:         mov     tmpw,r0
  62:         sys     close
  63:         mov     tmpr,r0
  64:         sys     close
  65:         sys     unlink; ftemp
  66:         jmp     loop
  67: 1:
  68:         mov     tmpw,r0
  69:         sys     close
  70:         sys     fork
  71:         br      5f
  72:         mov     r1,-(sp)
  73:         sys     wait
  74:         sys     signal; 2; inter
  75:         mov     (sp)+,r1
  76:         mov     a(r1),w(r1)
  77: 2:
  78:         mov     tmpr,r0
  79:         sys     read; buffer; 512.
  80:         tst     r0
  81:         beq     2f
  82:         add     $buffer,r0
  83:         mov     r0,bufend
  84:         mov     $buffer,r2
  85: 1:
  86:         movb    (r2)+,r0
  87:         jsr     pc,putchar
  88:         cmp     r2,bufend
  89:         blo     1b
  90:         br      2b
  91: 2:
  92:         mov     tmpr,r0
  93:         sys     close
  94:         sys     unlink; ftemp
  95:         tst     iflag
  96:         beq     1f
  97:         jmp     loop
  98: 1:
  99:         tst     qflag
 100:         bgt     1f
 101:         tst     (sp)+
 102:         dec     r3
 103:         bgt     1f
 104:         jmp     loop
 105: 1:      jmp     econ
 106:         jmp     loop
 107: 3:
 108:         mov     (sp),r2
 109:         mov     $2,r0
 110:         jsr     pc,allocate
 111: 1:
 112:         tstb    (r2)
 113:         beq     1f
 114:         movb    (r2)+,r0
 115:         jsr     pc,putchar
 116:         br      1b
 117: 1:
 118:         mov     r1,r0
 119:         mov     asmem,r1
 120:         jsr     pc,putword
 121:         mov     $2,r0
 122:         jsr     pc,allocate
 123:         mov     r1,r0
 124:         mov     asmem,r1
 125:         jsr     pc,putword
 126:         mov     r0,r1
 127:         br      4b
 128: 5:
 129:         mov     $2,r0
 130: 1:
 131:         sys     close
 132:         inc     r0
 133:         cmp     r0,$10.
 134:         blo     1b
 135:         sys     exec; edd; eda
 136:         sys     exit
 137: eda:    edd; ftemp; 0
 138: edd:    </bin/ed\0>
 139:         .even
 140: ftemp:  </tmp/ftmpa\0>
 141: erm:    <Cannot open temp. file\n>
 142:         .even
 143: tmpw:   .=.+2
 144: tmpr:   .=.+2
 145: /
 146: /	remove a 'file' from memory
 147: /
 148: remove:
 149:         mov     (sp)+,r3
 150:         bgt     5f
 151:         mov     $1,vflag
 152:         mov     asmem,r1
 153:         jsr     pc,rewind
 154:         mov     r(r1),-(sp)
 155: 4:
 156:         tst     iflag
 157:         beq     1f
 158:         jmp     loop
 159: 1:
 160:         jsr     pc,getword
 161:         bes     4f
 162:         mov     r0,r2
 163:         jsr     pc,ask
 164:         bec     1f
 165:         mov     r(r1),(sp)
 166:         br      4b
 167: 1:
 168:         jsr     pc,getword
 169:         br      2f
 170: 5:
 171:         mov     (sp),r0
 172:         jsr     pc,getspq
 173:         bec     2f
 174:         tst     qflag
 175:         blt     6f
 176:         mov     (sp),r1
 177:         jsr     pc,nothere
 178:         br      3f
 179: 2:
 180:         mov     r0,r1
 181:         jsr     pc,release
 182:         mov     r2,r1
 183:         jsr     pc,release
 184:         jsr     pc,rm
 185: 3:
 186:         tst     vflag
 187:         bne     3f
 188:         tst     iflag
 189:         beq     1f
 190:         jmp     loop
 191: 1:
 192:         tst     qflag
 193:         bgt     5b
 194: 6:
 195:         tst     (sp)+
 196:         dec     r3
 197:         bgt     5b
 198:         jmp     loop
 199: 3:
 200:         mov     asmem,r1
 201:         mov     (sp),r(r1)
 202:         br      4b
 203: 4:
 204:         tst     (sp)+
 205:         jmp     loop
 206: /
 207: /	rename a 'file'
 208: /
 209: rename:
 210:         mov     (sp)+,r3
 211:         bne     1f
 212:         jmp     error
 213: 1:
 214:         sub     $2,r3
 215:         blt     1f
 216: 5:
 217:         mov     (sp),r0
 218:         jsr     pc,getsp
 219:         bes     4f
 220:         tst     (sp)+
 221:         sub     $4,r(r1)
 222:         mov     (sp),r0
 223:         mov     r2,-(sp)
 224:         mov     r(r1),-(sp)
 225:         jsr     pc,getsp
 226:         bes     3f
 227:         mov     r2,-(sp)
 228:         mov     r0,r1
 229:         jsr     pc,release
 230:         jsr     pc,rm
 231:         mov     (sp)+,r0
 232:         mov     (sp)+,r(r1)
 233:         jsr     pc,alterword
 234:         mov     (sp)+,r1
 235:         jsr     pc,release
 236:         br      5f
 237: 3:
 238:         mov     (sp)+,r(r1)
 239:         mov     (sp)+,r1
 240:         jsr     pc,release
 241:         mov     $2,r0
 242:         jsr     pc,allocate
 243:         mov     (sp)+,r2
 244: 2:
 245:         movb    (r2)+,r0
 246:         beq     2f
 247:         jsr     pc,putchar
 248:         br      2b
 249: 2:
 250:         mov     r1,r0
 251:         mov     asmem,r1
 252:         jsr     pc,alterword
 253: 5:
 254:         tst     iflag
 255:         beq     2f
 256:         jmp     loop
 257: 2:
 258:         tst     r3
 259:         beq     2f
 260:         sub     $2,r3
 261:         bge     5b
 262: 1:
 263:         tst     (sp)+
 264:         jmp     error
 265: 2:
 266:         jmp     loop
 267: 4:
 268:         mov     (sp)+,r1
 269:         jsr     pc,nothere
 270:         tst     (sp)+
 271:         br      5b
 272: /
 273: /	list contents of asmem
 274: /
 275: list:
 276:         mov     $buffer,r2
 277:         movb    $'\n,(r2)+
 278:         jsr     pc,output
 279:         mov     (sp)+,r3
 280:         beq     1f
 281:         mov     $1,vflag
 282: 5:
 283:         tst     iflag
 284:         beq     2f
 285:         jmp     loop
 286: 2:
 287:         mov     (sp),r0
 288:         jsr     pc,getspq
 289:         bes     4f
 290:         mov     r2,r1
 291:         br      3f
 292: 1:
 293:         mov     asmem,r1
 294:         jsr     pc,fsfile
 295:         sub     $2,r(r1)
 296: 2:
 297:         tst     iflag
 298:         bne     2f
 299:         jsr     pc,backword
 300:         bes     2f
 301:         mov     r0,r1
 302: 3:
 303:         jsr     pc,getn
 304:         movb    $'\n,(r2)+
 305:         jsr     pc,output
 306:         tst     vflag
 307:         bne     1f
 308:         mov     asmem,r1
 309:         sub     $2,r(r1)
 310:         br      2b
 311: 1:
 312:         tst     qflag
 313:         bgt     5b
 314: 4:
 315:         tst     (sp)+
 316:         dec     r3
 317:         bgt     5b
 318: 2:
 319:         mov     $buffer,r2
 320:         movb    $'\n,(r2)+
 321:         jsr     pc,output
 322:         jmp     loop
 323: /
 324: /	list a 'file
 325: /
 326: listf:
 327:         mov     (sp)+,r3
 328:         bgt     4f
 329:         jmp     error
 330: 4:
 331:         mov     (sp),r0
 332:         jsr     pc,getspq
 333:         bes     3f
 334:         mov     r0,r4
 335:         mov     r2,r1
 336:         jsr     pc,rewind
 337:         mov     $buffer,r2
 338:         movb    $'\n,(r2)+
 339: 1:
 340:         jsr     pc,getchar
 341:         bes     1f
 342:         movb    r0,(r2)+
 343:         cmp     r2,$bufend
 344:         blo     1b
 345:         jsr     pc,output
 346:         br      1b
 347: 1:
 348:         mov     r4,r1
 349:         jsr     pc,rewind
 350:         movb    $':,(r2)+
 351:         cmp     r2,$bufend
 352:         blo     2f
 353:         jsr     pc,output
 354: 2:
 355:         movb    $'\n,(r2)+
 356: 1:
 357:         tst     iflag
 358:         beq     2f
 359:         jmp     loop
 360: 2:
 361:         cmp     r2,$bufend
 362:         blo     2f
 363:         jsr     pc,output
 364: 2:
 365:         jsr     pc,getchar
 366:         bes     1f
 367:         movb    r0,(r2)+
 368:         br      1b
 369: 1:
 370:         jsr     pc,output
 371: 3:
 372:         tst     qflag
 373:         bgt     4b
 374:         tst     (sp)+
 375:         dec     r3
 376:         bgt     4b
 377:         mov     $buffer,r2
 378:         movb    $'\n,(r2)+
 379:         jsr     pc,output
 380:         jmp     loop
 381: /
 382: fin:
 383:         jsr     pc,flush
 384:         jsr     pc,whead
 385:         4
 386: q:
 387:         jsr     pc,flush
 388:         jsr     pc,whead
 389:         sys     exit
 390: memck:  mov     (sp)+,r3
 391: 2:
 392:         ble     2f
 393:         mov     (sp)+,r1
 394:         cmpb    (r1),$'p
 395:         bne     1f
 396:         bis     $1,vflag
 397:         br      3f
 398: 1:
 399:         cmpb    (r1),$'f
 400:         bne     3f
 401:         bis     $2,vflag
 402: 3:
 403:         dec     r3
 404:         br      2b
 405: 2:
 406:         clr     freeh
 407:         mov     $freeb,r2
 408: 1:
 409:         clr     (r2)+
 410:         cmp     r2,$freen
 411:         blo     1b
 412:         mov     $headers,r2
 413: 2:
 414:         cmp     l(r2),$hsz
 415:         beq     6f
 416:         jsr     pc,ck
 417:         bec     1f
 418:         cmp     r2,asmem
 419:         beq     1f
 420:         mov     asmem,r1
 421:         jsr     pc,rewind
 422:         clr     r3
 423: 4:
 424:         inc     r3
 425:         jsr     pc,getword
 426:         bes     5f
 427:         cmp     r0,r2
 428:         bne     4b
 429: 6:
 430:         inc     freeh
 431: 1:
 432: cont:
 433:         add     $8.,r2
 434:         cmp     r2,$headend-4
 435:         blo     2b
 436:         mov     asmem,r1
 437:         jsr     pc,rewind
 438: 4:
 439:         jsr     pc,getword
 440:         bes     4f
 441:         tst     r(r0)
 442:         beq     2f
 443:         mov     r0,r2
 444:         jsr     pc,ck
 445:         bes     4b
 446: 2:
 447:         sub     $hblk,r0
 448:         jsr     r5,oct
 449:         mov     $1,r0
 450:         sys     write; re; 24.
 451:         cmp     vflag,$1
 452:         beq     4b
 453:         bit     $1,r3
 454:         beq     2f
 455:         jsr     pc,getword
 456:         mov     r0,r1
 457:         jsr     pc,release
 458:         br      3f
 459: 2:
 460:         jsr     pc,backword
 461:         add     $4,r(r1)
 462:         mov     r0,r1
 463:         jsr     pc,release
 464: 3:
 465:         jsr     pc,rm
 466:         clr     r3
 467:         br      4b
 468: 4:
 469:         mov     freeh,r0
 470:         jsr     r5,decml
 471:         mov     $1,r0
 472:         sys     write; frh; 14.
 473:         mov     $freeb,r2
 474:         mov     $1,r3
 475: 6:
 476:         cmp     r2,$freen
 477:         bhis    6f
 478:         mov     (r2)+,r0
 479:         beq     3f
 480:         jsr     r5,decml
 481:         mov     $1,r0
 482:         sys     write; frb; 18.
 483:         mov     r3,r0
 484:         jsr     r5,decml
 485:         mov     $1,r0
 486:         sys     write; lf; 1.
 487: 3:
 488:         asl     r3
 489:         br      6b
 490: 6:
 491:         mov     $1,r0
 492:         sys     write; lf; 1.
 493:         jmp     loop
 494: 5:
 495:         mov     r2,r0
 496:         sub     $hblk,r0
 497:         jsr     r5,oct
 498:         mov     $1,r0
 499:         sys     write; un; 26.
 500:         tst     vflag
 501:         beq     1b
 502:         mov     r2,r1
 503:         cmp     vflag,$2
 504:         beq     3f
 505:         jsr     pc,rewind
 506:         mov     $buffer,r2
 507: 2:
 508:         jsr     pc,getchar
 509:         bes     2f
 510:         movb    r0,(r2)+
 511:         cmp     r2,$buffer+80.
 512:         blo     2b
 513:         jsr     pc,output
 514:         br      2b
 515: 2:
 516:         movb    $'\n,(r2)+
 517:         jsr     pc,output
 518:         mov     r1,r2
 519:         cmp     vflag,$1
 520:         bne     3f
 521:         jmp     cont
 522: 3:
 523:         jsr     pc,release
 524:         jmp     cont
 525: /
 526: interrupt: 4
 527: /
 528: un:     < header not accounted for\n>
 529: re:     < part of asmem released\n>
 530: lf:     <\n>
 531: frh:    < free headers\n >
 532: frb:    < free blocks size >
 533: endc:   .even

Defined functions

cont defined in line 432; used 2 times
econ defined in line 6; used 2 times
ed defined in line 3; never used
eda defined in line 137; used 1 times
edd defined in line 138; used 2 times
endc defined in line 533; never used
erm defined in line 141; used 1 times
  • in line 18
fin defined in line 382; never used
frb defined in line 532; used 1 times
frh defined in line 531; used 1 times
ftemp defined in line 140; used 8 times
interrupt defined in line 526; never used
lf defined in line 530; used 2 times
list defined in line 275; never used
listf defined in line 326; never used
memck defined in line 390; never used
q defined in line 386; never used
re defined in line 529; used 1 times
remove defined in line 148; never used
rename defined in line 209; never used
tmpr defined in line 144; used 4 times
tmpw defined in line 143; used 5 times
un defined in line 528; used 1 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 616
Valid CSS Valid XHTML 1.0 Strict