Execute Computer/Zero: Difference between revisions

Content added Content deleted
(Added PL/M)
(RPL: add section)
Line 2,181: Line 2,181:
Linked list: 6
Linked list: 6
Prisoners dilemma: 0</pre>
Prisoners dilemma: 0</pre>

=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.8}}
{| class="wikitable"
! RPL code
! Comment
|-
|
{
≪ ''''RAM'''' SWAP GET ''''ACC'''' STO ≫
≪ ''''RAM'''' SWAP '''ACC''' PUT ≫
≪ ''''RAM'''' SWAP GET '''ACC''' + 256 MOD ''''ACC'''' STO ≫
≪ ''''RAM'''' SWAP GET '''ACC''' SWAP - 256 MOD ''''ACC'''' STO ≫
≪ '''IF''' ACC NOT '''THEN''' 1 - ''''PC'''' STO '''ELSE''' DROP '''END''' ≫
≪ 1 - ''''PC'''' STO ≫
≪ DROP 1 SF ≫
} ''''µCODE'''' STO
{ 32 } RDM ''''RAM'''' STO
0 ''''ACC'''' STO 0 ''''PC'''' STO 1 CF
'''WHILE''' 1 FC? REPEAT
'''PC''' 1 + DUP 32 MOD ''''PC'''' STO ''''RAM'''' SWAP GET
32 DUP2 MOD 1 + ROT ROT / FLOOR
'''IF THEN µCODE''' LAST GET EVAL '''ELSE''' DROP '''END'''
'''END ACC'''
≫ ‘'''RUN'''’ STO
|
'''µCODE''' ''( address -- new pointer value )''
LDA x
STA x
ADD x
SUB x
BRZ x
JMP x
STP
'''RUN''' ''( [ program ] -- accumulator )''
load program to memory
reset accumulator, counter and flag
loop until STP
increment pointer and read byte
instruction, addresss = divmod(byte,32)
if instruction <> NOP then execute
display accumulator
|}
{{in}}
<pre>
[ 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>
{{out}}
<pre>
5: 4
4: 56
3: 55
2: 6
1: 0
</pre>
The second program (multiplying 7 by 8) runs in 13 seconds on a basic HP-28S


=={{header|Wren}}==
=={{header|Wren}}==