def run(self, machine): if (Flag.SF in machine.flags) == (Flag.OF in machine.flags): return MachineUpdate() return MachineUpdate( registers={ Register.pc: machine.registers[self.value_register], })
def run(self, machine): if Flag.ZF not in machine.flags: return MachineUpdate() return MachineUpdate( registers={ Register.pc: machine.registers[self.value_register], })
def run(self, machine): if Flag.ZF not in machine.flags: return MachineUpdate() current = machine.registers[Register.pc].int_value() offset = machine.registers[self.value_register].int_value() updated_pc = Word.from_int(current + offset + self.size) return MachineUpdate(registers={ Register.pc: updated_pc, })
def run(self, machine): if (Flag.SF in machine.flags) == (Flag.OF in machine.flags): return MachineUpdate() current = machine.registers[Register.pc].int_value() offset = self.value_word.int_value() updated_pc = Word.from_int(current + offset + self.size) return MachineUpdate(registers={ Register.pc: updated_pc, })
def run(self, machine): dest = machine.registers[Register.sp] return MachineUpdate( memory={dest: machine.registers[self.value_register]}, registers={ Register.sp: machine.registers[Register.sp].incremented(-4) })
def run(self, machine): pop_address = machine.registers[Register.sp].incremented(4) payload = machine.memory.read_word(pop_address.int_value()) return MachineUpdate(registers={ self.value_register: payload, Register.sp: pop_address })
def run(self, machine): updated_sp_address = machine.registers[Register.sp].incremented(4) popped_pc = machine.memory.read_word(updated_sp_address.int_value()) return MachineUpdate(registers={ Register.pc: popped_pc, Register.sp: updated_sp_address })
def run(self, machine): current = machine.registers[Register.pc].int_value() offset = machine.registers[self.value_register].int_value() return MachineUpdate( registers={ Register.pc: Word.from_int(current + offset + self.size), })
def run(self, machine): result, flags = subtract_word(machine.registers[self.dest_register], machine.registers[self.source_register]) return MachineUpdate(registers={ self.dest_register: result, }, flags=flags)
def run(self, machine): return_pointer = machine.registers[Register.pc].incremented(self.size) updated_pc = self.value_word.incremented(13) # todo: spec error return MachineUpdate( memory={machine.registers[Register.sp]: return_pointer}, registers={ Register.pc: updated_pc, Register.sp: machine.registers[Register.sp].incremented(-4) })
def run(self, machine): if machine.stdin: user_int = machine.stdin.pop(0) else: user_input = input() user_int = ord(user_input[0]) user_byte = Byte(user_int) return MachineUpdate( memory={machine.registers[self.value_register]: user_byte}, )
def run(self, machine): return_pointer = machine.registers[Register.pc].incremented(self.size) increment_amount = machine.registers[self.value_register] return MachineUpdate( memory={machine.registers[Register.sp]: return_pointer}, registers={ Register.pc: machine.registers[Register.pc].incremented(increment_amount), Register.sp: machine.registers[Register.sp].incremented(-4) })
def run(self, machine): payload = machine.registers[self.source_register] return MachineUpdate(registers={self.dest_register: payload})
def run(self, machine): char = machine.registers[self.value_register].low_byte() return MachineUpdate(stdout=char)
def run(self, machine): char = self.value_word.low_byte() return MachineUpdate(stdout=char)
def run(self, machine): result, _ = bitwise_or(machine.registers[self.dest_register], machine.registers[self.source_register]) return MachineUpdate(registers={self.dest_register: result})
def run(self, machine): return MachineUpdate(registers={Register.pc: self.value_word})
def run(self, machine): return MachineUpdate( registers={ Register.pc: machine.registers[self.value_register], })
def run(self, machine): _, flags = bitwise_and(machine.registers[self.dest_register], machine.registers[self.source_register]) return MachineUpdate(registers={self.dest_register: result}, flags=flags)
def run(self, machine): result = bitwise_not(machine.registers[self.value_register]) return MachineUpdate(registers={self.value_register: result})
def run(self, machine): result = machine.registers[self.dest_register].low_byte() return MachineUpdate( memory={machine.registers[self.source_register]: result})
def run(self, machine): result = machine.registers[self.dest_register] return MachineUpdate(memory={self.source_word: result})
def run(self, machine): result, flags = bitwise_xor(machine.registers[self.dest_register], self.source_word) return MachineUpdate(registers={self.dest_register: result}, flags=flags)
def run(self, machine): _, flags = bitwise_and(machine.registers[self.dest_register], self.source_word) return MachineUpdate(flags=flags)
def run(self, machine): if Flag.ZF not in machine.flags: return MachineUpdate() return MachineUpdate( registers={Register.pc: self.value_word.incremented(13)})
def run(self, machine): return MachineUpdate()
def run(self, machine): address = self.source_word.int_value() loaded_word = machine.memory.read_word(address) return MachineUpdate(registers={self.dest_register: loaded_word})