const Bus = @import("../../../lib.zig").Bus; pub fn fmt17(comptime InstrFn: type) InstrFn { const Arm32 = @typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?; return struct { fn inner(cpu: Arm32, _: Bus, _: u16) void { // Copy Values from Current Mode const ret_addr = cpu.r[15] - 2; const cpsr = cpu.cpsr.raw; // Switch Mode cpu.changeMode(.Supervisor); cpu.cpsr.t.write(false); // Force ARM Mode cpu.cpsr.i.write(true); // Disable normal interrupts cpu.r[14] = ret_addr; // Resume Execution cpu.spsr.raw = cpsr; // Previous mode CPSR cpu.r[15] = 0x0000_0008; cpu.pipe.reload(cpu); } }.inner; }