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

1.1       root        1: #
                      2: # 33iofile.s
                      3: #
                      4: # FILE HOUSEKEEPING OPERATIONS
                      5: #
                      6: _DEFNAME:
                      7:        calls   $0,_getname
                      8:        movl    r1,sp
                      9:        bisw2   $FDEF,FUNIT(r0)
                     10:        jmp     (r8)
                     11: _BUFF:
                     12:        cvtbw   (r10)+,_bufopt
                     13:        jmp     (r8)
                     14: _RESET:
                     15:        cvtbl   (r10),r3                #attempt to rewind only if stdin
                     16:        bneq    l3301           # and no name is given
                     17:        cmpl    *(sp),$stdin
                     18:        bneq    l3301
                     19:        tstb    stdin+FNAME
                     20:        bneq    l3301
                     21:        pushl   stdin+FBUF
                     22:        calls   $1,_rewind
                     23:        tstl    r0              # -1 => error
                     24:        blss    eseek
                     25:        addl2   $3,r10
                     26:        addl2   $4,sp           #clear stack
                     27:        bicw2   $EOF+EOLN,stdin+FUNIT
                     28:        bisw2   $SYNC,stdin+FUNIT
                     29:        jmp     (r8)
                     30: l3301:
                     31:        calls   $0,_getname
                     32:        movl    r1,sp
                     33:        movl    r0,r6
                     34:        pushal  rdopen
                     35:        pushal  FNAME(r6)
                     36:        calls   $2,_fopen
                     37:        tstl    r0
                     38:        beql    eopen
                     39:        movl    r0,FBUF(r6)
                     40:        bisw2   $SYNC+FREAD,FUNIT(r6)
                     41:        jmp     (r8)
                     42: eseek:
                     43:        movl    stdin+PFNAME,_file
                     44:        movw    $ESEEK,_perrno
                     45:        jbr     error
                     46: eopen:
                     47:        movl    PFNAME(r6),_file
                     48:        movw    $EOPEN,_perrno
                     49:        jbr     error
                     50: _REWRITE:
                     51:        calls   $0,_getname
                     52:        movl    r1,sp
                     53:        movl    r0,r6
                     54:        movl    PFNAME(r6),_file
                     55:        pushal  wtopen
                     56:        pushal  FNAME(r6)
                     57:        calls   $2,_fopen
                     58:        tstl    r0
                     59:        beql    ecreat
                     60:        movl    r0,FBUF(r6)
                     61:        bisw2   $EOF+FWRITE,FUNIT(r6)
                     62:        jmp     (r8)
                     63: ecreat:
                     64:        movw    $ECREATE,_perrno
                     65:        jbr     error
                     66: _FLUSH:
                     67:        incl    r10
                     68:        calls   $1,_unit
                     69:        bbc     $fWRITE,FUNIT(r7),l3302
                     70:        pushl   FBUF(r7)
                     71:        calls   $1,_fflush
                     72: l3302:
                     73:        jmp     (r8)
                     74: _REMOVE:
                     75:        cvtbl   (r10)+,r3       #r3 has filename length
                     76:        bneq    l3303
                     77:        cvtwl   (r10)+,r3
                     78: l3303:
                     79:        movl    r3,r6           #r6 has stack length
                     80:        blbc    r6,l3304
                     81:        incl    r6
                     82: l3304:
                     83:        addl3   r3,sp,r1        #r1 pts to end of name
                     84: l3305:
                     85:        cmpb    -(r1),$blank    #delete trailing blanks
                     86:        bneq    l3306           #(note: could use "spanc" here)
                     87:        clrb    (r1)
                     88:        sobgtr  r3,l3305
                     89: l3306:
                     90:        movl    sp,_file        #remove file
                     91:        pushl   sp
                     92:        calls   $1,_unlink
                     93:        tstl    r0
                     94:        bneq    eremove
                     95:        addl2   r6,sp
                     96:        jmp     (r8)
                     97: eremove:
                     98:        movl    _file,sp        #recover filename
                     99:        movw    $EREMOVE,_perrno
                    100:        jbr     error
                    101: _MESSAGE:
                    102:        incl    r10
                    103:        calls   $0,_pflush
                    104:        pushal  stderr
                    105:        calls   $1,_unit
                    106:        jmp     (r8)

unix.superglobalmegacorp.com

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