Execute Computer/Zero: Difference between revisions

Content added Content deleted
(RPL: add section)
(RPL: optimized version)
Line 2,189: Line 2,189:
|-
|-
|
|
{
{
≪ ''''RAM'''' SWAP GET ''''ACC'''' STO
SWAP DROP ''''RAM'''' SWAP 1 + GET
≪ ''''RAM'''' SWAP '''ACC''' PUT ≫
≪ ''''RAM'''' SWAP 1 + 3 PICK PUT ≫
≪ ''''RAM'''' SWAP GET '''ACC''' + 256 MOD ''''ACC'''' STO
≪ ''''RAM'''' SWAP 1 + GET + 256 MOD ≫
≪ ''''RAM'''' SWAP GET '''ACC''' SWAP - 256 MOD ''''ACC'''' STO
≪ ''''RAM'''' SWAP 1 + GET - 256 MOD ≫
≪ '''IF''' ACC NOT '''THEN''' 1 - ''''PC'''' STO '''ELSE''' DROP '''END''' ≫
≪ '''IF''' OVER NOT '''THEN''' ROT DROP SWAP '''ELSE''' DROP '''END''' ≫
1 - ''''PC'''' STO
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 ''''ACC'''' STO 0 ''''PC'''' STO 1 CF
0 0 1 CF
'''WHILE''' 1 FC? REPEAT
'''WHILE''' 1 FC? '''REPEAT'''
'''PC''' 1 + DUP 32 MOD ''''PC'''' STO ''''RAM'''' SWAP GET
SWAP 1 + DUP 32 MOD ROT ROT ''''RAM'''' SWAP GET
32 DUP2 MOD 1 + ROT ROT / FLOOR
32 DUP2 MOD ROT ROT / FLOOR
'''IF THEN µCODE''' LAST GET EVAL '''ELSE''' DROP '''END'''
'''IF THEN 'µCODE'''' LAST GET EVAL '''ELSE''' DROP
'''END ACC'''
'''END END'''
‘'''RUN'''’ STO
‘RUN’ STO
|
|
'''µCODE''' ''( address -- new pointer value )''
'''µ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
[ 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
[ 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
[ 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
[ 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}}