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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

: LOAD-WRD OVER 1+ OVER 0 100 U/ RR LO, DROP FF AND RR LK, ;<br />

: ZERO-UORD DUP 1+ R CLR, R CLR , ;<br />

: GOFORTN FJND<br />

RO R DECU,<br />

RO R3 STC,<br />

RO R DECW,<br />

RO R2 STC,<br />

HERE 12 4 a d 3COD OR,<br />

HERE 10 + 0 100 U/<br />

SUAP 2600 OR , DROP<br />

DUP FF and 5COO OR ,<br />

0 100 U/ 4COO OR , DROP<br />

R6 R4 LDC,<br />

R4 R INCW,<br />

R7 R4 LDC,<br />

R4 R INCU,<br />

R6 EXIT,<br />

HERE a + , HERE a + ,<br />

R2 RO LDC,<br />

RO R lNCU,<br />

R3 RO LDC,<br />

RO R INCU,<br />

Address <strong>of</strong> target <strong>FORTH</strong> word to stack<br />

Save R2/R3 on RSteck<br />

R3 to RStack (via RO)<br />

R2 to RStack (via RO)<br />

Lou byte <strong>of</strong> HERE+12 to R3<br />

High byte <strong>of</strong> HERE+IO to R2<br />

Low byte <strong>of</strong> target addr to R5<br />

High byte <strong>of</strong> target addr to R6<br />

Load jwp addr to R6/7<br />

Jwp to target addr via R6/7<br />

IP and EV to return to prior routine<br />

Restore IP<br />

: SQRT DUP 8000 AND IF NEGATE THEN 60 5 0 DO OVER OVER / + 2 / LOOP SWAP DROP ;<br />

25

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

Saved successfully!

Ooh no, something went wrong!