1: / dusg -- summarize disk usage
   2: 
   3: .globl  putc, flush, _end
   4:         mov     $1,obuf
   5:         mov     (sp)+,r5
   6:         tst     (sp)+
   7: 1:
   8:         dec     r5
   9:         bgt     2f
  10:         tstb    buf1
  11:         beq     3f
  12:         jsr     r5,flush; obuf
  13:         sys     exit
  14: 3:
  15:         mov     $dot,r0
  16:         br      3f
  17: 2:
  18:         mov     (sp)+,r0
  19: 3:
  20:         cmpb    (r0),$'-
  21:         bne     2f
  22:         cmpb    1(r0),$'a
  23:         bne     3f
  24:         inc     aflg
  25:         br      1b
  26: 3:
  27:         cmpb    1(r0),$'s
  28:         bne     1b
  29:         dec     aflg
  30:         br      1b
  31: 2:
  32:         mov     $buf1,r1
  33: 2:
  34:         movb    (r0)+,(r1)+
  35:         bne     2b
  36:         dec     r1
  37:         clr     buf3+10.
  38:         mov     $_end,iptr
  39:         mov     $_end,brk
  40:         sys     break; _end
  41:         jsr     pc,tree
  42:         tst     aflg
  43:         bpl     1b
  44:         jsr     r5,name
  45:         br      1b
  46: 
  47: tree:
  48:         sys     stat; buf1; buf2
  49:         bes     1f
  50:         bic     $!60000,buf2+4
  51:         bit     $20000,buf2+4
  52:         beq     2f
  53: 1:
  54:         clr     r4
  55:         rts     pc
  56: 2:
  57:         mov     $_end,r2
  58:         mov     buf2+2,r3
  59: 1:
  60:         cmp     r2,iptr
  61:         bhis    1f
  62:         cmp     r3,(r2)+
  63:         bne     1b
  64:         clr     r4
  65:         jsr     r5,cname
  66:         rts     pc
  67: 1:
  68:         cmp     r2,brk
  69:         blo     1f
  70:         add     $512.,brk
  71:         sys     break; brk: ..
  72: 1:
  73:         mov     r3,(r2)+
  74:         mov     r2,iptr
  75:         cmp     $40000,buf2+4
  76:         beq     1f
  77:         jsr     pc,gsize
  78:         jsr     r5,cname
  79:         rts     pc
  80: 1:
  81:         jsr     pc,gsize
  82:         mov     r4,r3
  83:         sys     open; buf1; 0
  84:         bec     1f
  85:         rts     pc
  86: 1:
  87:         mov     r0,-(sp)
  88:         mov     r1,-(sp)
  89: 1:
  90:         mov     2(sp),r0
  91:         sys     read; buf3; 16.
  92:         bes     1f
  93:         tst     r0
  94:         beq     1f
  95:         tst     buf3
  96:         beq     1b
  97:         cmp     buf3+2,$".\0
  98:         beq     1b
  99:         cmp     buf3+2,$"..
 100:         bne     2f
 101:         tst     buf3+4
 102:         beq     1b
 103: 2:
 104:         mov     $buf3+2,r2
 105:         mov     (sp),r1
 106:         movb    $'/,(r1)+
 107:         cmpb    -2(r1),$'/
 108:         bne     2f
 109:         dec     r1
 110: 2:
 111:         movb    (r2)+,(r1)+
 112:         bne     2b
 113:         dec     r1
 114:         mov     r3,-(sp)
 115:         jsr     pc,tree
 116:         mov     r4,r3
 117:         add     (sp)+,r3
 118:         br      1b
 119: 1:
 120:         mov     (sp)+,r1
 121:         clrb    (r1)
 122:         mov     (sp)+,r0
 123:         sys     close
 124:         mov     r3,r4
 125:         tst     aflg
 126:         bmi     1f
 127:         jsr     r5,name
 128: 1:
 129:         rts     pc
 130: 
 131: cname:
 132:         tst     aflg
 133:         bgt     name
 134:         rts     r5
 135: 
 136: name:
 137:         jsr     pc,pnum
 138:         mov     $011,r0
 139:         jsr     pc,pchar
 140:         mov     $buf1,r2
 141: 1:
 142:         movb    (r2)+,r0
 143:         beq     1f
 144:         jsr     pc,pchar
 145:         br      1b
 146: 1:
 147:         mov     $'\n,r0
 148:         jsr     pc,pchar
 149:         rts     r5
 150: 
 151: gsize:
 152:         mov     r5,-(sp)
 153:         mov     buf2+10.,r5             / size
 154:         movb    buf2+9.,r4
 155:         add     $511.,r5
 156:         adc     r4
 157:         alsc    $-9,r4
 158:         cmp     r5,$8.
 159:         blo     1f
 160:         mov     r5,-(sp)
 161:         add     $255.,r5
 162:         alsc    $-8,r4
 163:         add     (sp)+,r5
 164: 1:
 165:         mov     r5,r4
 166:         mov     (sp)+,r5
 167:         rts     pc
 168: 
 169: pnum:
 170:         mov     r4,-(sp)
 171:         mov     r5,-(sp)
 172:         mov     r4,r5
 173:         jsr     pc,1f
 174:         mov     (sp)+,r5
 175:         mov     (sp)+,r4
 176:         rts     pc
 177: 1:
 178:         clr     r4
 179:         dvd     $10.,r4
 180:         mov     r5,-(sp)
 181:         mov     r4,r5
 182:         beq     1f
 183:         jsr     pc,1b
 184: 1:
 185:         mov     (sp)+,r0
 186:         add     $'0,r0
 187:         jsr     pc,pchar
 188:         rts     pc
 189: 
 190: pchar:
 191:         jsr     r5,putc; obuf
 192:         rts     pc
 193: 
 194: dot:    <.\0>
 195: 
 196:         .bss
 197: 
 198: iptr:   .=.+2
 199: buf1:   .=.+100.
 200: buf2:   .=.+40.
 201: buf3:   .=.+18.
 202: aflg:   .=.+2
 203: obuf:   .=.+520.

Defined functions

brk defined in line 71; used 3 times
cname defined in line 131; used 2 times
dot defined in line 194; used 1 times
  • in line 15
gsize defined in line 151; used 2 times
name defined in line 136; used 3 times
pchar defined in line 190; used 4 times
pnum defined in line 169; used 1 times
tree defined in line 47; used 2 times

Defined variables

aflg defined in line 202; used 5 times
buf1 defined in line 199; used 5 times
buf2 defined in line 200; used 7 times
buf3 defined in line 201; used 7 times
iptr defined in line 198; used 3 times
obuf defined in line 203; used 3 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 595
Valid CSS Valid XHTML 1.0 Strict