Skip to content

Instantly share code, notes, and snippets.

@MizukiSonoko
Last active April 17, 2017 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MizukiSonoko/6cdf25cee7268cd176309f6516b4b464 to your computer and use it in GitHub Desktop.
Save MizukiSonoko/6cdf25cee7268cd176309f6516b4b464 to your computer and use it in GitHub Desktop.
RAM
r = [0] * 7
pc = 1
def M(i,j):
def _m():
r[i] = r[j]
return False
return _m
def J(i,j,k):
def _j():
if r[i] == r[j]:
global pc
pc = k
return True
return False
return _j
def S(i):
def _s():
r[i] += 1
return False
return _s
def Z(i):
def _z():
r[i] = 0
return False
return _z
def E():
def _e():
print("=== result ===")
for i in range(0,len(r)):
print( "{:>3}".format(i), end="|")
print()
for i in range(0,len(r)):
print( "{:>3}".format(r[i]), end="|")
print()
print("R(0) = ",r[0])
print("==============")
return _e
def D():
pass
if __name__ == "__main__":
ins = []
r[1] = 7
r[2] = 3
ins = [
D,
M(3,2),
J(1,3,6),
S(3),
S(0),
J(0,0,2),
E()
]
while True:
if not ins[pc]():
pc += 1
if pc == len(ins) - 1:
ins[pc]()
quit()
@MizukiSonoko
Copy link
Author

命令

D, # dummy
M(3,2),
J(1,3,6),
S(3),
S(0),
J(0,0,2),
E

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment