Compact AssembleiInterpreter.py

This commit is contained in:
Matt07734 2020-04-27 15:16:53 -07:00 committed by GitHub
parent 738a2f8a7c
commit 3e87235965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 121 deletions

View File

@ -1,126 +1,29 @@
fte = input("What file to execute?> ") a, b, c, d, e, f, g, h = '00000000'
cell = ''
a="0" with open(input('What file to execute?> '), 'r') as F:
b="0" for row in F:
c="0"
d="0"
e="0"
f="0"
g="0"
h="0"
cell=""
def lts(s):
str1 = ""
for ele in s:
str1 += ele
return str1
def Forward():
if cell == "":
return "a"
if cell == "a":
return "b"
if cell == "b":
return "c"
if cell == "c":
return "d"
if cell == "d":
return "e"
if cell == "e":
return "f"
if cell == "f":
return "g"
if cell == "g":
return "h"
if cell == "h":
return ""
def GetCell():
if cell == "":
return "nocell"
if cell == "a":
return "a"
if cell == "b":
return "b"
if cell == "c":
return "c"
if cell == "d":
return "d"
if cell == "e":
return "e"
if cell == "f":
return "f"
if cell == "g":
return "g"
if cell == "h":
return "h"
def Backward():
if cell == "":
return "h"
if cell == "a":
return ""
if cell == "b":
return "a"
if cell == "c":
return "b"
if cell == "d":
return "c"
if cell == "e":
return "d"
if cell == "f":
return "e"
if cell == "g":
return "f"
if cell == "h":
return "g"
with open(fte, 'r') as fte2:
for row in fte2:
for x in str(row): for x in str(row):
if x == "!": if x == '!':
cell = Forward() if cell == '': cell = 'a'
if x == "?": elif 'a' <= cell <= 'g': cell = chr(ord(cell) + 1)
cell = Backward() elif cell == 'h': cell = ''
if x == "#": if x == '?':
x2 = str(a + b + c + d + e + f + g + h) if cell == '': cell = 'h'
x3 = lts(x2) elif cell == 'a': cell = ''
print(x3) elif 'b' <= cell <= 'h': cell = chr(ord(cell) - 1)
if x == '#':
print(a + b + c + d + e + f + g + h)
if x == "+": if x == "+":
if cell == "a": if cell == 'a' and a == '0': a = '1'
if a == "0": elif cell == 'b' and b == '0': b = '1'
a = "1" elif cell == 'c' and c == '0': c = '1'
if cell == "b": elif cell == 'd' and d == '0': d = '1'
if b == "0": elif cell == 'e' and e == '0': e = '1'
b = "1" elif cell == 'f' and f == '0': f = '1'
if cell == "c": elif cell == 'g' and g == '0': g = '1'
if c == "0": elif cell == 'h' and h == '0': h = '1'
c = "1"
if cell == "d":
if d == "0":
d = "1"
if cell == "e":
if e == "0":
e = "1"
if cell == "f":
if f == "0":
f = "1"
if cell == "g":
if g == "0":
g = "1"
if cell == "h":
if h == "0":
h = "1"
if x == ".": if x == ".":
print(cell) print(cell)
if x == ",": if x == ",":
a = "0" a, b, c, d, e, f, g, h = '00000000'
b = "0" cell = ''
c = "0"
d = "0"
e = "0"
f = "0"
g = "0"
h = "0"
cell = ""