Example #1
0
def movlo(self, assembler, instruction, args):
    """ `movlo r1, 1336` => r1[15:0] = 1336  """
    registers = register.parse_registers(assembler, args, 1, 1)
    set_instruction_registers(instruction, registers, OPCODE_LENGTH)
    immediate = get_immediate(args[2])
    instruction[16:] = int_to_bin_fill(immediate, 16)
    return instruction
Example #2
0
def load(self, assembler, instruction, args):
    """ load r1, r2, imm : r1 = Mem(r2+imm) """
    registers = register.parse_registers(assembler, args, 1, 2)
    set_instruction_registers(instruction, registers, OPCODE_LENGTH)
    immediate = get_immediate(args[3])
    instruction[16:] = int_to_bin_fill(immediate, 16)
    return instruction
Example #3
0
def addi(self, assembler, instruction, args):
    registers = register.parse_registers(assembler, args, 1, 2)
    #print(registers)
    set_instruction_registers(instruction, registers, OPCODE_LENGTH)
    immediate = get_immediate(args[-1])
    immediate = int_to_bin_fill(immediate, 16)
    instruction[16:] = immediate
    return instruction
Example #4
0
 def anon(self, assembler, instruction, args):
     registers = register.parse_registers(assembler, args, args_idx,
                                          num_registers)
     set_instruction_registers(instruction, registers, dest_start_index)
     return instruction
Example #5
0
def push(self, assembler, instruction, args):
    """ `push r1` => Mem(SP) = r1, SP++  """
    assembler.sp_offset += 1
    registers = register.parse_registers(assembler, args, 1, 1)
    set_instruction_registers(instruction, registers, OPCODE_LENGTH)
    return instruction
Example #6
0
def mul(self, assembler, instruction, args):
    registers = register.parse_registers(assembler, args, 1, 3)
    set_instruction_registers(instruction, registers, OPCODE_LENGTH)
    return instruction
Example #7
0
def store(self, assembler, instruction, args):
    """ store r1, r2 : Mem(r2) = r1 """
    registers = register.parse_registers(assembler, args, 1, 2)
    set_instruction_registers(instruction, registers, OPCODE_LENGTH)
    return instruction