You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.2 KiB
Python
74 lines
1.2 KiB
Python
6 years ago
|
def addr(reg, a, b, c):
|
||
|
reg[c] = reg[a] + reg[b]
|
||
|
return reg
|
||
|
|
||
|
def addi(reg, a, b, c):
|
||
|
reg[c] = reg[a] + b
|
||
|
return reg
|
||
|
|
||
|
def mulr(reg, a, b, c):
|
||
|
reg[c] = reg[a] * reg[b]
|
||
|
return reg
|
||
|
|
||
|
def muli(reg, a, b, c):
|
||
|
reg[c] = reg[a] * b
|
||
|
return reg
|
||
|
|
||
|
def banr(reg, a, b, c):
|
||
|
reg[c] = reg[a] & reg[b]
|
||
|
return reg
|
||
|
|
||
|
def bani(reg, a, b, c):
|
||
|
reg[c] = reg[a] & b
|
||
|
return reg
|
||
|
|
||
|
def borr(reg, a, b, c):
|
||
|
reg[c] = reg[a] | reg[b]
|
||
|
return reg
|
||
|
|
||
|
def bori(reg, a, b, c):
|
||
|
reg[c] = reg[a] | b
|
||
|
return reg
|
||
|
|
||
|
def setr(reg, a, b, c):
|
||
|
reg[c] = reg[a]
|
||
|
return reg
|
||
|
|
||
|
def seti(reg, a, b, c):
|
||
|
reg[c] = a
|
||
|
return reg
|
||
|
|
||
|
def gtir(reg, a, b, c):
|
||
|
reg[c] = 1 if a > reg[b] else 0
|
||
|
return reg
|
||
|
|
||
|
def gtri(reg, a, b, c):
|
||
|
reg[c] = 1 if reg[a] > b else 0
|
||
|
return reg
|
||
|
|
||
|
def gtrr(reg, a, b, c):
|
||
|
reg[c] = 1 if reg[a] > reg[b] else 0
|
||
|
return reg
|
||
|
|
||
|
def eqir(reg, a, b, c):
|
||
|
reg[c] = 1 if a == reg[b] else 0
|
||
|
return reg
|
||
|
|
||
|
def eqri(reg, a, b, c):
|
||
|
reg[c] = 1 if reg[a] == b else 0
|
||
|
return reg
|
||
|
|
||
|
def eqrr(reg, a, b, c):
|
||
|
reg[c] = 1 if reg[a] == reg[b] else 0
|
||
|
return reg
|
||
|
|
||
|
ops = [
|
||
|
addr, addi,
|
||
|
mulr, muli,
|
||
|
banr, bani,
|
||
|
borr, bori,
|
||
|
setr, seti,
|
||
|
gtir, gtri, gtrr,
|
||
|
eqir, eqri, eqrr
|
||
|
]
|