Execute Computer/Zero: Difference between revisions
Content added Content deleted
(RPL: add section) |
(RPL: optimized version) |
||
Line 2,189: | Line 2,189: | ||
|- |
|- |
||
| |
| |
||
{ |
|||
≪ ''''RAM'''' SWAP |
≪ SWAP DROP ''''RAM'''' SWAP 1 + GET ≫ |
||
≪ ''''RAM'''' SWAP |
≪ ''''RAM'''' SWAP 1 + 3 PICK PUT ≫ |
||
≪ ''''RAM'''' SWAP |
≪ ''''RAM'''' SWAP 1 + GET + 256 MOD ≫ |
||
≪ ''''RAM'''' SWAP |
≪ ''''RAM'''' SWAP 1 + GET - 256 MOD ≫ |
||
≪ '''IF''' |
≪ '''IF''' OVER NOT '''THEN''' ROT DROP SWAP '''ELSE''' DROP '''END''' ≫ |
||
≪ |
≪ ROT DROP SWAP ≫ |
||
≪ DROP 1 SF ≫ |
≪ DROP 1 SF ≫ |
||
} ''''µCODE'''' STO |
} ''''µCODE'''' STO |
||
Line 2,201: | Line 2,201: | ||
≪ |
≪ |
||
{ 32 } RDM ''''RAM'''' STO |
{ 32 } RDM ''''RAM'''' STO |
||
0 |
0 0 1 CF |
||
'''WHILE''' 1 FC? REPEAT |
'''WHILE''' 1 FC? '''REPEAT''' |
||
SWAP 1 + DUP 32 MOD ROT ROT ''''RAM'''' SWAP GET |
|||
32 DUP2 MOD |
32 DUP2 MOD ROT ROT / FLOOR |
||
'''IF THEN µCODE''' LAST GET EVAL '''ELSE''' DROP |
'''IF THEN 'µCODE'''' LAST GET EVAL '''ELSE''' DROP |
||
'''END |
'''END END''' |
||
≫ |
≫ ‘RUN’ STO |
||
| |
| |
||
'''µCODE''' ''( address -- |
'''µCODE''' ''( counter accumulator address -- counter accumulator )'' |
||
LDA x |
LDA x |
||
STA x |
STA x |
||
Line 2,216: | Line 2,216: | ||
BRZ x |
BRZ x |
||
JMP x |
JMP x |
||
STP |
STP x |
||
'''RUN''' ''( [ program ] -- accumulator )'' |
'''RUN''' ''( [ program ] -- counter accumulator )'' |
||
load program to memory |
load program to memory |
||
reset accumulator, counter and flag |
reset accumulator, counter and flag |
||
Line 2,225: | Line 2,225: | ||
increment pointer and read byte |
increment pointer and read byte |
||
instruction, addresss = divmod(byte,32) |
instruction, addresss = divmod(byte,32) |
||
if instruction <> NOP then execute |
if instruction <> NOP then execute it |
||
display accumulator |
display accumulator |
||
Line 2,232: | Line 2,232: | ||
<pre> |
<pre> |
||
[ 35 100 224 2 2 ] RUN |
[ 35 100 224 2 2 ] RUN |
||
[ 44 106 76 43 141 75 168 192 44 224 8 7 0 1 ] RUN |
|||
[ 46 79 109 78 47 77 48 145 171 80 192 46 224 1 1 0 8 1 ] RUN |
|||
[ 45 111 69 112 71 0 78 0 171 79 192 46 224 32 0 28 1 0 0 0 6 0 2 26 5 20 3 30 1 22 4 24 ] RUN |
|||
[ 0 0 224 0 0 35 157 178 35 93 174 33 127 65 194 32 127 64 192 35 93 33 126 99 ] RUN |
|||
</pre> |
</pre> |
||
{{out}} |
{{out}} |