feat(cpu): implement THUMB format 17
This commit is contained in:
parent
1378c809e6
commit
027e4fb57b
|
@ -37,6 +37,7 @@ const format13 = @import("cpu/thumb/format13.zig").format13;
|
||||||
const format14 = @import("cpu/thumb/format14.zig").format14;
|
const format14 = @import("cpu/thumb/format14.zig").format14;
|
||||||
const format15 = @import("cpu/thumb/format15.zig").format15;
|
const format15 = @import("cpu/thumb/format15.zig").format15;
|
||||||
const format16 = @import("cpu/thumb/format16.zig").format16;
|
const format16 = @import("cpu/thumb/format16.zig").format16;
|
||||||
|
const format17 = @import("cpu/thumb/format17.zig").format17;
|
||||||
const format18 = @import("cpu/thumb/format18.zig").format18;
|
const format18 = @import("cpu/thumb/format18.zig").format18;
|
||||||
const format19 = @import("cpu/thumb/format19.zig").format19;
|
const format19 = @import("cpu/thumb/format19.zig").format19;
|
||||||
|
|
||||||
|
@ -479,8 +480,7 @@ fn thumbPopulate() [0x400]ThumbInstrFn {
|
||||||
|
|
||||||
lut[i] = format13(S);
|
lut[i] = format13(S);
|
||||||
} else if (i >> 2 & 0xFF == 0xDF) {
|
} else if (i >> 2 & 0xFF == 0xDF) {
|
||||||
// Format 17 | Software Interrupt
|
lut[i] = format17();
|
||||||
lut[i] = thumbUndefined;
|
|
||||||
} else if (i >> 6 & 0xF == 0b1000) {
|
} else if (i >> 6 & 0xF == 0b1000) {
|
||||||
const L = i >> 5 & 1 == 1;
|
const L = i >> 5 & 1 == 1;
|
||||||
const offset = i & 0x1F;
|
const offset = i & 0x1F;
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
const Bus = @import("../../Bus.zig");
|
||||||
|
const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi;
|
||||||
|
const InstrFn = @import("../../cpu.zig").ThumbInstrFn;
|
||||||
|
|
||||||
|
pub fn format17() InstrFn {
|
||||||
|
return struct {
|
||||||
|
fn inner(cpu: *Arm7tdmi, _: *Bus, _: u16) void {
|
||||||
|
// Copy Values from Current Mode
|
||||||
|
const r15 = cpu.r[15];
|
||||||
|
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] = r15; // Resume Execution
|
||||||
|
cpu.spsr.raw = cpsr; // Previous mode CPSR
|
||||||
|
cpu.r[15] = 0x0000_0008;
|
||||||
|
}
|
||||||
|
}.inner;
|
||||||
|
}
|
Loading…
Reference in New Issue