Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = []
- with open ("HelloWorld.dis") as file:
- for line in file:
- temp = []
- for cell in line.split("\t"):
- temp.append(int(cell))
- data.append(temp);
- inst = x = y = 0
- try:
- while (x < len(data[0]) and y < len(data) and x >= 0 and y >= 0):
- inst = data[y][x]
- if (inst%3 == 0):
- #ADD
- #If the number%3 is 0, add the value below it to it.
- data[y][x] += data[y+1][x]
- if (inst%3 == 1):
- #SUBTRACT
- #If the number%3 is 1, subtract the value below it from it
- data[y][x] -= data[y+1][x]
- if (inst%7 == 0):
- #OUTPUT
- #If the number%7 is 0, output the ascii character with the value of the cell
- print(chr(data[y][x]))
- if (inst%7 == 1):
- #INPUT
- #If the number%7 is 1, store the value of the ascii character inputted in the cell
- data[y][x] = ord(input())
- if (inst%2 == 0):
- #SET X
- #If the number is even, inc the y ptr and set the x ptr to the value of the cell
- y += 1
- x = data[y][x]
- if (inst%2 == 1):
- #SET Y
- #If the number is odd, inc the x ptr and set the y ptr to the value of the cell
- x += 1
- y = data[y][x]
- x += 1
- except Exception as e:
- print ("Exception: " + str(e))
- print ("Instruction = " + str(inst) + " (now = " + str(data[y][x]) + ") x = " + str(x) + " y = " + str(y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement