feat(cpu): implement like 1 THUMB instruction
This commit is contained in:
		
							
								
								
									
										32
									
								
								src/cpu/thumb/format3.zig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/cpu/thumb/format3.zig
									
									
									
									
									
										Normal 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; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user