update python
FossilOrigin-Name: 9811a839b0facdbe99bb05591fbced7f8e7d9cd2914e633567ef4a2dadb705e9
This commit is contained in:
parent
97bb387ec3
commit
2e5d99348a
1 changed files with 27 additions and 28 deletions
|
@ -40,28 +40,19 @@ def findEntry(named):
|
||||||
def rxGetInput():
|
def rxGetInput():
|
||||||
return ord(sys.stdin.read(1))
|
return ord(sys.stdin.read(1))
|
||||||
|
|
||||||
def rxDisplayCharacter(target):
|
def rxDisplayCharacter():
|
||||||
global stack
|
global stack
|
||||||
if target == 'console':
|
if stack[-1] > 0 and stack[-1] < 128:
|
||||||
if stack[-1] > 0 and stack[-1] < 128:
|
if stack[-1] == 8:
|
||||||
if stack[-1] == 8:
|
sys.stdout.write(chr(stack.pop()))
|
||||||
sys.stdout.write(chr(stack.pop()))
|
sys.stdout.write(chr(32))
|
||||||
sys.stdout.write(chr(32))
|
sys.stdout.write(chr(8))
|
||||||
sys.stdout.write(chr(8))
|
|
||||||
else:
|
|
||||||
sys.stdout.write(chr(stack.pop()))
|
|
||||||
else:
|
else:
|
||||||
sys.stdout.write("\033[2J\033[1;1H")
|
sys.stdout.write(chr(stack.pop()))
|
||||||
stack.pop()
|
|
||||||
sys.stdout.flush()
|
|
||||||
return ''
|
|
||||||
else:
|
else:
|
||||||
return str(chr(stack.pop()))
|
sys.stdout.write("\033[2J\033[1;1H")
|
||||||
|
stack.pop()
|
||||||
def processOpcode(opcode):
|
sys.stdout.flush()
|
||||||
global ip, stack, address, memory
|
|
||||||
if opcode == 0: # nop
|
|
||||||
pass
|
|
||||||
|
|
||||||
def i_no():
|
def i_no():
|
||||||
pass
|
pass
|
||||||
|
@ -216,14 +207,26 @@ def i_en():
|
||||||
global ip, memory, stack, address
|
global ip, memory, stack, address
|
||||||
ip = 9000000
|
ip = 9000000
|
||||||
|
|
||||||
instructions = [i_no, i_li, i_du, i_dr, i_sw, i_pu, i_po, i_ju, i_ca, i_cc, i_re, i_eq, i_ne, i_lt, i_gt, i_fe, i_st, i_ad, i_su, i_mu, i_di, i_an, i_or, i_xo, i_sh, i_zr, i_en]
|
def i_ie():
|
||||||
|
stack.push(1)
|
||||||
|
|
||||||
|
def i_iq():
|
||||||
|
stack.pop()
|
||||||
|
stack.push(0)
|
||||||
|
stack.push(0)
|
||||||
|
|
||||||
|
def i_ii():
|
||||||
|
stack.pop()
|
||||||
|
rxDisplayCharacter()
|
||||||
|
|
||||||
|
instructions = [i_no, i_li, i_du, i_dr, i_sw, i_pu, i_po, i_ju, i_ca, i_cc, i_re, i_eq, i_ne, i_lt, i_gt, i_fe, i_st, i_ad, i_su, i_mu, i_di, i_an, i_or, i_xo, i_sh, i_zr, i_en, i_ie, i_iq, i_ii]
|
||||||
|
|
||||||
def validateOpcode(opcode):
|
def validateOpcode(opcode):
|
||||||
I0 = opcode & 0xFF
|
I0 = opcode & 0xFF
|
||||||
I1 = (opcode >> 8) & 0xFF
|
I1 = (opcode >> 8) & 0xFF
|
||||||
I2 = (opcode >> 16) & 0xFF
|
I2 = (opcode >> 16) & 0xFF
|
||||||
I3 = (opcode >> 24) & 0xFF
|
I3 = (opcode >> 24) & 0xFF
|
||||||
if (I0 >= 0 and I0 <= 26) and (I1 >= 0 and I1 <= 26) and (I2 >= 0 and I2 <= 26) and (I3 >= 0 and I3 <= 26):
|
if (I0 >= 0 and I0 <= 29) and (I1 >= 0 and I1 <= 29) and (I2 >= 0 and I2 <= 29) and (I3 >= 0 and I3 <= 29):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -246,7 +249,6 @@ def injectString( s, to ):
|
||||||
|
|
||||||
def execute(word, output = 'console'):
|
def execute(word, output = 'console'):
|
||||||
global ip, memory, stack, address
|
global ip, memory, stack, address
|
||||||
TOB = ''
|
|
||||||
ip = word
|
ip = word
|
||||||
address.append(0)
|
address.append(0)
|
||||||
while ip < 100000 and len(address) > 0:
|
while ip < 100000 and len(address) > 0:
|
||||||
|
@ -263,13 +265,10 @@ def execute(word, output = 'console'):
|
||||||
if I2 != 0: instructions[I2]()
|
if I2 != 0: instructions[I2]()
|
||||||
if I3 != 0: instructions[I3]()
|
if I3 != 0: instructions[I3]()
|
||||||
else:
|
else:
|
||||||
if opcode == 1000:
|
print('Invalid Bytecode', opcode, ip)
|
||||||
TOB = TOB + rxDisplayCharacter(output)
|
ip = 2000000
|
||||||
else:
|
|
||||||
print('Invalid Bytecode', opcode, ip)
|
|
||||||
ip = 2000000
|
|
||||||
ip = ip + 1
|
ip = ip + 1
|
||||||
return TOB
|
return
|
||||||
|
|
||||||
def words():
|
def words():
|
||||||
header = memory[2]
|
header = memory[2]
|
||||||
|
|
Loading…
Reference in a new issue