Execute Brain****: Difference between revisions

Added Axe
m (→‎{{header|Sidef}}: minor fix)
(Added Axe)
Line 397:
Goodbye, World!
</pre>
 
=={{header|Axe}}==
In this implementation, the array is limited to 768 bytes due to OS constraints. Call BF with pointers to the (null-terminated) program and input.
 
<lang axe>Lbl BF
r₁→P
r₂→I
L₁→D
Fill(D,768,0)
 
While {P}
{P}→C
If C='+'
{D}++
ElseIf C='-'
{D}--
ElseIf C='>'
D++
ElseIf C='<'
D--
ElseIf C='.'
Disp {D}▶Char
ElseIf C=','
{I}→{D}
I++
ElseIf C='['?{D}=0
NEXT(P)→P
ElseIf C=']'
PREV(P)→P
End
P++
End
Return
 
Lbl NEXT
r₁++
1→S
While S
If {r₁}='['
S++
ElseIf {r₁}=']'
S--
End
r₁++
End
r₁
Return
 
Lbl Prev
r₁--
1→S
While S
If {r₁}=']'
S++
ElseIf {r₁}='['
S--
End
r₁--
End
r₁
Return</lang>
 
'''Example'''
<lang axe>"++++++++++++++++++++++++++++++++[>+>+<<-]>>+++++++++++++++++++++++++<<++++++++++[>>.-<.<-]"→Str1
BF(Str1,0)</lang>
 
'''Output'''
<pre>9▪8▪7▪6▪5▪4▪3▪2▪1▪0▪</pre>
 
=={{header|BASIC}}==
Anonymous user