blob: 625226ab15c1c6dc1ea868c45b058c21317f194e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
from ctypes import c_uint32
class Instruction:
size = 4 # Instruction size in bytes
def __init__(self):
pass
def compile(self):
# return the binstream of the instruction in a c_uint32
pass
def execute(self):
# executes the instruction and returns the next program counter
return
class InstructionSet:
def __init__(self, init=None):
self.instructions = dict()
def instruction(self, ins):
if ins.name not in self.instructions:
self.instructions[ins.name] = ins
return ins
# NOTE: We don't need to treat pseudoinstructions in an special way yet,
# but we separate the decorator for clarity
pseudoinstruction = instruction
if __name__ == "__main__":
# TODO This is the interface i'd love to have
addins = add("x5","x2","zero")
j("labelName")
|