Annotation of 40BSD/cmd/px/33iofile.s, revision 1.1.1.1

1.1       root        1: #
                      2: # Copyright (c) 1979 Regents of the University of California
                      3: #
                      4: # char sccsid[] = "@(#)33iofile.s 4.2 10/14/80";
                      5: #
                      6: # FILE HOUSEKEEPING OPERATIONS
                      7: #
                      8: _DEFNAME:
                      9:        incl    r10
                     10:        calls   $4,_getname
                     11:        bisw2   $FDEF,FUNIT(r0)
                     12:        jmp     (r8)
                     13: _BUFF:
                     14:        cvtbl   (r10)+,r0
                     15:        bneq    l3301
                     16:        pushl   $0
                     17:        brb     l3303
                     18: l3301:
                     19:        cmpl    r0,$1
                     20:        bgtr    l3302
                     21:        jmp     (r8)
                     22: l3302:
                     23:        pushal  __sobuf
                     24: l3303:
                     25:        pushl   stdout+FBUF
                     26:        calls   $2,_setbuf
                     27:        jmp     (r8)
                     28: _RESET:
                     29:        incl    r10
                     30:        tstl    8(sp)           #attempt to rewind only if stdin
                     31:        bneq    l3304           # and no name is given
                     32:        cmpl    *12(sp),$stdin
                     33:        bneq    l3304
                     34:        tstb    stdin+FNAME
                     35:        bneq    l3304
                     36:        pushl   stdin+FBUF
                     37:        calls   $1,_rewind
                     38:        tstl    r0              # -1 => error
                     39:        blss    eseek
                     40:        addl2   $16,sp          #clear stack
                     41:        bicw2   $EOF+EOLN,stdin+FUNIT
                     42:        bisw2   $SYNC,stdin+FUNIT
                     43:        jmp     (r8)
                     44: l3304:
                     45:        calls   $4,_getname
                     46:        movl    r0,r6
                     47:        pushal  rdopen
                     48:        pushal  FNAME(r6)
                     49:        calls   $2,_fopen
                     50:        tstl    r0                      #check for valid open
                     51:        bneq    l3305
                     52:        bbc     $fTEMP,FUNIT(r6),eopen  #if TEMP file, set at EOF
                     53:        bisw2   $EOF,FUNIT(r6)
                     54: l3305:
                     55:        movl    r0,FBUF(r6)
                     56:        bisw2   $SYNC+FREAD,FUNIT(r6)
                     57:        jmp     (r8)
                     58: eseek:
                     59:        movl    stdin+PFNAME,_file
                     60:        movw    $ESEEK,_perrno
                     61:        jbr     error
                     62: eopen:
                     63:        movl    PFNAME(r6),_file
                     64:        movw    $EOPEN,_perrno
                     65:        jbr     error
                     66: _REWRITE:
                     67:        incl    r10
                     68:        calls   $4,_getname
                     69:        movl    r0,r6
                     70:        movl    PFNAME(r6),_file
                     71:        pushal  wtopen
                     72:        pushal  FNAME(r6)
                     73:        calls   $2,_fopen
                     74:        tstl    r0
                     75:        beql    ecreat
                     76:        movl    r0,FBUF(r6)
                     77:        bisw2   $EOF+FWRITE,FUNIT(r6)
                     78:        jmp     (r8)
                     79: ecreat:
                     80:        movw    $ECREATE,_perrno
                     81:        jbr     error
                     82: _FILE:
                     83:        incl    r10
                     84:        pushl   FBUF(r7)
                     85:        jmp     (r8)
                     86: _FLUSH:
                     87:        incl    r10
                     88:        calls   $1,_unit
                     89:        bbc     $fWRITE,FUNIT(r7),l3306
                     90:        pushl   FBUF(r7)
                     91:        calls   $1,_fflush
                     92: l3306:
                     93:        jmp     (r8)
                     94: _REMOVE:
                     95:        incl    r10
                     96:        movl    (sp)+,r4                #r4 has max name length
                     97:        movl    (sp)+,r5                #r5 pts to name
                     98:        locc    $blank,r4,(r5)          #check for trailing blanks
                     99:        subl2   r0,r4                   #deduct blanks if any
                    100:        addl3   $2,r4,r6                #r6 has name + 1 aligned to word
                    101:        bicl2   $1,r6
                    102:        subl2   r6,sp                   #allocate space
                    103:        movc5   r4,(r5),$0,r6,(sp)      #move in name with zero end
                    104:        pushl   sp                      #unlink file
                    105:        calls   $1,_unlink
                    106:        tstl    r0                      #check for errors
                    107:        bneq    eremove
                    108:        addl2   r6,sp                   #deallocate space
                    109:        jmp     (r8)
                    110: eremove:
                    111:        movl    sp,_file                #point to name
                    112:        movw    $EREMOVE,_perrno
                    113:        jbr     error
                    114: _MESSAGE:
                    115:        incl    r10
                    116:        calls   $0,_pflush
                    117:        pushal  stderr
                    118:        calls   $1,_unit
                    119:        jmp     (r8)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.