Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Subleq/MiniScript/subleq.mini
Normal file
39
Task/Subleq/MiniScript/subleq.mini
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue