40 lines
881 B
Plaintext
40 lines
881 B
Plaintext
memory = []
|
|
step = 3
|
|
currentAddress = 0
|
|
out = ""
|
|
|
|
process = function(address)
|
|
A = memory[address].val
|
|
B = memory[address + 1].val
|
|
C = memory[address + 2].val
|
|
nextAddress = address + step
|
|
|
|
if A == -1 then
|
|
memory[B] = input
|
|
else if B == -1 then
|
|
globals.out = globals.out + char(memory[A].val)
|
|
else
|
|
memory[B] = str(memory[B].val - memory[A].val)
|
|
if memory[B] < 1 then nextAddress = C
|
|
end if
|
|
return nextAddress
|
|
end function
|
|
|
|
print
|
|
memory = input("Enter SUBLEQ program").split
|
|
|
|
print
|
|
print "Running Program"
|
|
print "-------------------"
|
|
processing = currentAddress < memory.len
|
|
while processing
|
|
currentAddress = process(currentAddress)
|
|
if currentAddress >= memory.len or currentAddress == -1 then
|
|
processing = false
|
|
end if
|
|
end while
|
|
|
|
print out
|
|
print "-------------------"
|
|
print "Execution Complete"
|