Compare commits

..

1 Commits

Author SHA1 Message Date
Rekai Nyangadzayi Musuka 9648dda3cb feat(cpu): implement like 1 THUMB instruction 2022-01-14 07:26:27 -04:00
1 changed files with 32 additions and 0 deletions

32
src/cpu/thumb/format3.zig Normal file
View File

@ -0,0 +1,32 @@
const std = @import("std");
const Bus = @import("../../Bus.zig");
const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi;
const InstrFn = @import("../../cpu.zig").ThumbInstrFn;
pub fn format3(comptime op: u2, comptime rd: u3) InstrFn {
return struct {
fn inner(cpu: *Arm7tdmi, _: *Bus, opcode: u16) void {
const offset = @truncate(u8, opcode);
switch (op) {
0b00 => {
cpu.r[rd] = offset;
cpu.cpsr.n.unset();
cpu.cpsr.z.write(offset == 0);
std.debug.panic("TODO: Implement mov R{}, #0x{X:0>2}", .{ rd, offset });
},
0b01 => {
std.debug.panic("TODO: Implement cmp R{}, #0x{X:0>2}", .{ rd, offset });
},
0b10 => {
std.debug.panic("TODO: Implement add R{}, #0x{X:0>2}", .{ rd, offset });
},
0b11 => {
std.debug.panic("TODO: Implement sub R{}, #0x{X:0>2}", .{ rd, offset });
},
}
}
}.inner;
}