1: ldfps = 170100^tst
   2: /
   3:         ldfps   $240
   4: 
   5:         clr     argflg
   6:         cmp     (sp)+,$2
   7:         blt     begin
   8:         tst     (sp)+
   9:         mov     (sp),r2
  10:         jsr     r5,atof; getch1
  11:         inc     argflg
  12:         br      begin1
  13: begin:
  14:         tst     argflg
  15:         beq 9f; sys exit; 9:
  16:         jsr     r5,atof; getch
  17: begin1:
  18:         tstf    fr0
  19:         cfcc
  20:         bpl 9f; jmp ouch; 9:
  21:         bne 9f; sys exit; 9:
  22:         cmpf    big,fr0
  23:         cfcc
  24:         bgt 9f; jmp ouch; 9:
  25: /
  26:         movf    $f100,fr1
  27:         cmpf    fr0,fr1
  28:         cfcc
  29:         bge     1f
  30:         mov     $pt,r3
  31: 3:
  32:         cmp     r3,$ptend
  33:         bhis    1f
  34:         movif   (r3)+,fr1
  35:         cmpf    fr1,fr0
  36:         cfcc
  37:         blt     3b
  38:         tst     -(r3)
  39: 3:
  40:         movif   (r3),fr0
  41:         jsr     r5,ftoa; wrchar
  42:         mov     $'\n,r0
  43:         jsr     r5,wrchar
  44:         tst     (r3)+
  45:         cmp     r3,$ptend
  46:         blo     3b
  47:         movf    $f100,fr0
  48: /
  49: 1:
  50:         divf    $two,fr0
  51:         modf    $one,fr0
  52:         movf    fr1,fr0
  53:         mulf    $two,fr0
  54:         addf    $one,fr0
  55:         movif   $tsiz8,fr1
  56:         movf    fr1,fr5
  57:         movf    fr0,nn
  58: /
  59: /
  60: /
  61: /	clear the sieve table
  62: /
  63: 2:
  64:         mov     $table,r3
  65: 3:
  66:         cmp     r3,$table+tabsiz
  67:         bhis    3f
  68:         clrb    (r3)+
  69:         br      3b
  70: /
  71: /	run the sieve
  72: /
  73: 3:
  74:         movf    nn,fr0
  75:         addf    fr5,fr0
  76:         jsr     r5,sqrt
  77:         movf    fr0,v
  78: /
  79:         movf    nn,fr0
  80:         movif   $3.,fr1
  81:         jsr     pc,5f
  82:         movif   $5.,fr1
  83:         jsr     pc,5f
  84:         movif   $7.,fr1
  85:         jsr     pc,5f
  86:         movif   $11.,fr1
  87:         mov     $factab+2,r4
  88: 4:
  89:         jsr     pc,5f
  90:         mov     (r4)+,kazoo
  91: kazoo   =.+2
  92:         addf    $kazoo,fr1
  93:         cmp     r4,$ftabend
  94:         blo     3f
  95:         mov     $factab,r4
  96: 3:
  97:         cmpf    v,fr1
  98:         cfcc
  99:         bge     4b
 100:         br      1f
 101: /
 102: /
 103: 5:
 104:         movf    fr0,fr2
 105:         divf    fr1,fr2
 106:         modf    $one,fr2
 107:         mulf    fr1,fr3
 108:         subf    fr0,fr3
 109:         cfcc
 110:         bpl     3f
 111:         addf    fr1,fr3
 112: 3:
 113:         cmpf    fr5,fr3
 114:         cfcc
 115:         ble     3f
 116:         movfi   fr3,r0
 117:         ashc    $-3.,r0
 118:         ash     $-13.,r1
 119:         bic     $177770,r1
 120:         bisb    bittab(r1),table(r0)
 121:         addf    fr1,fr3
 122:         br      3b
 123: 3:
 124:         rts     pc
 125: /
 126: /
 127: /	get one character form the argument string.
 128: getch1:
 129:         movb    (r2)+,r0
 130:         rts     r5
 131: /
 132: /	now get the primes from the table
 133: /	and print them.
 134: /
 135: 1:
 136: /
 137:         movf    nn,fr0
 138:         clr     r3
 139:         br      4f
 140: /
 141: 1:
 142:         inc     r3
 143:         inc     r3
 144:         cmp     r3,$tsiz8
 145:         bge     2b
 146: /
 147: 4:
 148: /
 149:         jsr     pc,prime
 150:         bec     3f
 151:         movf    nn,fr0
 152:         jsr     r5,ftoa; wrchar
 153:         mov     $'\n,r0
 154:         jsr     r5,wrchar
 155: 3:
 156:         movf    nn,fr0
 157:         addf    $two,fr0
 158:         movf    fr0,nn
 159:         br      1b
 160: /
 161: /
 162: /
 163: /
 164: prime:
 165:         mov     r3,r4
 166:         ashc    $-3.,r4
 167:         ash     $-13.,r5
 168:         bic     $177770,r5
 169:         bitb    bittab(r5),table(r4)
 170:         bne     1f
 171:         sec
 172: 1:
 173:         rts     pc
 174: /
 175: /
 176: /
 177: /
 178: one     = 40200
 179: half    = 40000
 180: opower  = 34400
 181: power   = 44000
 182: f100    = 41710
 183: /
 184: /	get one character from the console.
 185: /	called from atof.
 186: /
 187: getch:
 188:         clr     r0
 189:         sys     read; ch; 1
 190:         bec 9f; sys exit; 9:
 191:         tst r0; bne 9f; sys exit; 9:
 192:         mov     ch,r0
 193:         rts     r5
 194: /
 195: /
 196: /	write one character on the console
 197: /	called from ftoa.
 198: /
 199: wrchar:
 200:         tst     iobuf
 201:         bne     1f
 202:         mov     $iobuf+2,iobuf
 203: 1:
 204:         movb    r0,*iobuf
 205:         inc     iobuf
 206:         cmp     iobuf,$iobuf+514.
 207:         blo     1f
 208:         mov     $1,r0
 209:         sys     write; iobuf+2; 512.
 210:         mov     $iobuf+2,iobuf
 211: 1:
 212:         rts     r5
 213: /
 214:         .bss
 215: iobuf:  .=.+518.
 216:         .text
 217: /
 218: /
 219: /	read and convert a line from the console into fr0.
 220: /
 221: atof:
 222:         mov     r1,-(sp)
 223:         movif   $10.,r3
 224:         clrf    r0
 225: 1:
 226:         jsr     r5,*(r5)
 227:         sub     $'0,r0
 228:         cmp     r0,$9.
 229:         bhi     2f
 230:         mulf    r3,r0
 231:         movif   r0,r1
 232:         addf    r1,r0
 233:         br      1b
 234: 2:
 235:         cmp     r0,$' -'0
 236:         beq     1b
 237: /
 238:         mov     (sp)+,r1
 239:         tst     (r5)+
 240:         rts     r5
 241: /
 242: /
 243: ftoa:
 244:         mov     $ebuf,r2
 245: 1:
 246:         movf    fr0,fr1
 247:         divf    $ten,fr1
 248:         movf    fr1,fr2
 249:         modf    $one,fr2
 250:         movf    fr3,-(sp)
 251:         mulf    $ten,fr3
 252:         negf    fr3
 253:         addf    fr0,fr3
 254:         movfi   fr3,-(r2)
 255:         movf    (sp)+,fr0
 256:         tstf    fr0
 257:         cfcc
 258:         bne     1b
 259: 1:
 260:         mov     (r2)+,r0
 261:         add     $60,r0
 262:         jsr     r5,*(r5)
 263:         cmp     r2,$ebuf
 264:         blo     1b
 265:         tst     (r5)+
 266:         rts     r5
 267: /
 268: /
 269: /
 270: /	replace the f.p. number in fr0 by its square root
 271: /
 272: sqrt:
 273:         movf    r0,r1           / a
 274:         tstf    fr0
 275:         cfcc
 276:         beq     2f
 277:         bgt     1f
 278:         sec
 279:         rts     r5              / sqrt(-a)
 280: 1:
 281:         seti
 282:         movf    fr0,-(sp)
 283:         asr     (sp)
 284:         add     $20100,(sp)
 285:         movf    (sp)+,fr0
 286:         movif   $2,r3           / constant 2
 287:         mov     $4,r0
 288: 1:
 289:         movf    r1,r2
 290:         divf    r0,r2
 291:         addf    r2,r0
 292:         divf    r3,r0           / x = (x+a/x)/2
 293:         dec     r0
 294:         bgt     1b
 295: 2:
 296:         clc
 297:         rts     r5
 298: /
 299: /
 300: buf:    .=.+38.
 301: ebuf:
 302: /
 303: /
 304: /
 305: /	complain about a number which the program
 306: /	is unable to digest
 307: ouch:
 308:         mov     $2,r0
 309:         sys     write; 1f; 2f-1f
 310:         jmp     begin
 311: /
 312: 1:      <Ouch.\n>
 313: 2:      .even
 314: /
 315: /
 316: one     = 40200
 317: two     = 40400
 318: four    = 40600
 319: six     = 40700
 320: ten     = 41040
 321: /
 322:         .data
 323: bittab: .byte   1, 2, 4, 10, 20, 40, 100, 200
 324: big:    056177; 177777; 177777; 177777
 325: /
 326: pt:     2.; 3.; 5.; 7.; 11.; 13.; 17.; 19.; 23.; 29.; 31.; 37.; 41.; 43.
 327:         47.; 53.; 59.; 61.; 67.; 71.; 73.; 79.; 83.; 89.; 97.
 328: ptend:
 329: nl:     <\n>
 330: sp5:    <     >
 331:         .even
 332: /
 333: /
 334: factab:
 335:         41040; 40400; 40600; 40400; 40600; 40700; 40400; 40700
 336:         40600; 40400; 40600; 40700; 40700; 40400; 40700; 40600
 337:         40400; 40700; 40600; 40700; 41000; 40600; 40400; 40600
 338:         40400; 40600; 41000; 40700; 40600; 40700; 40400; 40600
 339:         40700; 40400; 40700; 40700; 40600; 40400; 40600; 40700
 340:         40400; 40700; 40600; 40400; 40600; 40400; 41040; 40400
 341: ftabend:
 342: /
 343:         .bss
 344: ch:     .=.+2
 345: t:      .=.+8
 346: n:      .=.+8
 347: v:      .=.+8
 348: nn:     .=.+8
 349: place:  .=.+8
 350: /
 351: tabsiz  = 1000.
 352: tsiz8   = 8000.
 353: table:  .=.+tabsiz
 354: argflg: .=.+2
 355:         .text

Defined functions

atof defined in line 221; used 2 times
begin defined in line 13; used 2 times
begin1 defined in line 17; used 1 times
  • in line 12
buf defined in line 300; never used
ebuf defined in line 301; used 2 times
f100 defined in line 182; used 2 times
four defined in line 318; never used
ftoa defined in line 243; used 2 times
getch defined in line 187; used 1 times
  • in line 16
getch1 defined in line 128; used 1 times
  • in line 10
half defined in line 179; never used
kazoo defined in line 91; used 2 times
one defined in line 316; used 4 times
opower defined in line 180; never used
ouch defined in line 307; used 2 times
power defined in line 181; never used
prime defined in line 164; used 1 times
six defined in line 319; never used
sqrt defined in line 272; used 1 times
  • in line 76
ten defined in line 320; used 2 times
two defined in line 317; used 3 times
wrchar defined in line 199; used 4 times

Defined variables

argflg defined in line 354; used 3 times
big defined in line 324; used 1 times
  • in line 22
bittab defined in line 323; used 2 times
ch defined in line 344; used 2 times
factab defined in line 334; used 2 times
ftabend defined in line 341; used 1 times
  • in line 93
iobuf defined in line 215; used 10 times
n defined in line 346; never used
nl defined in line 329; never used
nn defined in line 348; used 7 times
place defined in line 349; never used
pt defined in line 326; used 1 times
  • in line 30
ptend defined in line 328; used 2 times
sp5 defined in line 330; never used
t defined in line 345; never used
table defined in line 353; used 4 times
tabsiz defined in line 351; used 2 times
tsiz8 defined in line 352; used 2 times
v defined in line 347; used 2 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 328
Valid CSS Valid XHTML 1.0 Strict