SPU-II: use undefined1 as breakpoint

This commit is contained in:
Noam Preil 2020-08-21 18:19:23 -04:00 committed by Andrew Kelley
parent 222e23c678
commit f448b518f8
2 changed files with 13 additions and 2 deletions

View File

@ -11,6 +11,9 @@ pub fn Interpreter(comptime Bus: type) type {
/// This is set to true when we hit an undefined0 instruction, allowing it to
/// be used as a trap for testing purposes
undefined0: bool = false,
/// This is set to true when we hit an undefined1 instruction, allowing it to
/// be used as a trap for testing purposes. undefined1 is used as a breakpoint.
undefined1: bool = false,
bus: Bus,
pub fn ExecuteBlock(self: *@This(), comptime size: ?u32) !void {
@ -122,7 +125,11 @@ pub fn Interpreter(comptime Bus: type) type {
// Break out of the loop, and let the caller decide what to do
return;
},
.undefined1 => return error.BadInstruction,
.undefined1 => {
self.undefined1 = true;
// Break out of the loop, and let the caller decide what to do
return;
},
.signext => if ((val0 & 0x80) != 0)
(val0 & 0xFF) | 0xFF00
else

View File

@ -1265,7 +1265,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
.riscv64 => {
mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.ebreak.toU32());
},
.spu_2 => {},
.spu_2 => {
try self.code.resize(self.code.items.len + 2);
var instr = Instruction{ .condition = .always, .input0 = .zero, .input1 = .zero, .modify_flags = false, .output = .discard, .command = .undefined1 };
mem.writeIntLittle(u16, self.code.items[self.code.items.len - 2 ..][0..2], @bitCast(u16, instr));
},
else => return self.fail(src, "TODO implement @breakpoint() for {}", .{self.target.cpu.arch}),
}
return .none;