Execute Brain****: Difference between revisions
→{{header|Arturo}}
Drkameleon (talk | contribs) No edit summary |
Drkameleon (talk | contribs) |
||
Line 646:
*********************************/
Tape
DataPointer
InstructionPointer
// Look for jumps in
// in the Jumps table
precomputeJumps: {
stack
jumphash
instrPointer
loop instrPointer<CodeLength {
command:
if command="[" { stack: stack+instrPointer } {
if command="]" {
target:
deleteBy stack
}
}
instrPointer: instrPointer+1
}
jumphash
Line 675:
// Check if current state is valid
StateIsValid: {
all #(0<=DataPointer DataPointer<
}
// Compile the program
interpret: {
loop
command:
if inp=13 { inp:
▲ set Tape DataPointer inp
}
if Tape.[DataPointer]=0 { InstructionPointer: Jumps.[
}
if Tape.[DataPointer]!=0 { InstructionPointer: Jumps.[
}
InstructionPointer: InstructionPointer+1
}
}
if
Code :
CodeLength :
Jumps : precomputeJumps
interpret ~
</lang>
|