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
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
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
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
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
def mul(self, assembler, instruction, args): registers = register.parse_registers(assembler, args, 1, 3) set_instruction_registers(instruction, registers, OPCODE_LENGTH) return instruction
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