26.10.2013 Views

Sieve of Eratosthenes benchmarks for the Z8 FORTH microcontroller

Sieve of Eratosthenes benchmarks for the Z8 FORTH microcontroller

Sieve of Eratosthenes benchmarks for the Z8 FORTH microcontroller

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

APPENDIX C<br />

'Ihis section defines <strong>the</strong> <strong>FORTH</strong> words required in <strong>the</strong> optimization <strong>of</strong> <strong>the</strong> outer loop <strong>of</strong><br />

<strong>the</strong> <strong>FORTH</strong> benchmark <strong>for</strong> <strong>the</strong> sieve algorithm discussed in Section 6. The W Q ~ used S in<br />

<strong>the</strong> outer loop optimization make use <strong>of</strong> locations 60 through 69 <strong>of</strong> <strong>the</strong> 28 register file.<br />

Register<br />

Fi le<br />

Address Description <strong>of</strong> Definition<br />

60/61 Prime count<br />

62/63 1nCk.X<br />

54/65 Array size (SIZE)<br />

66/67 Address <strong>of</strong> <strong>the</strong> FLAGS array<br />

68/69<br />

LIMIT (Used to limit duplicate markings <strong>of</strong> nonprimes)<br />

: do-codp 62 R POP, 63 R POP, Initialize starting value <strong>of</strong> index<br />

64 SIZE-ADDR LOAD-WORD, Copy <strong>of</strong> array size to register file<br />

66 FLAGS LOAD-WORD, Copy <strong>of</strong> FLAGS addr to register file<br />

68 R INCW, do, ; Increment SIZE to do SIZE+l iterations<br />

: LTBAI R9 63 RR LD. Copy <strong>of</strong> INDEX to working register 8/9<br />

R8 62 RR LD,<br />

R9 67 RR ADD,<br />

88 66 RR ADC,<br />

R10 R8 LDC,<br />

R10 R10 rr OR, ;<br />

Add FLAGS address to Index<br />

Load R10 via pointer at R8/9<br />

Set condition codes in <strong>Z8</strong> flag register<br />

: Lirnit>i:if, 68 62 RR CP, Test LIMIT > INDEX<br />

le if, If LIMIT < INDEX skip out<br />

ecl if, IF LIMIT(H)=INDEX(H) test Low byte<br />

69 63 RR CP, Test low bytes<br />

ult if,<br />

SWAP <strong>the</strong>n,<br />

if LIPBIT(L)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!