Compare commits

..

2 Commits

1 changed files with 26 additions and 6 deletions

View File

@ -240,15 +240,23 @@ pub const Arm7tdmi = struct {
pub fn panic(self: *const Self, comptime format: []const u8, args: anytype) noreturn { pub fn panic(self: *const Self, comptime format: []const u8, args: anytype) noreturn {
var i: usize = 0; var i: usize = 0;
while (i < 16) : (i += 4) { while (i < 16) : (i += 4) {
std.debug.print("R{}: 0x{X:0>8}\tR{}: 0x{X:0>8}\tR{}: 0x{X:0>8}\tR{}: 0x{X:0>8}\n", .{ i, self.r[i], i + 1, self.r[i + 1], i + 2, self.r[i + 2], i + 3, self.r[i + 3] }); const i_1 = i + 1;
const i_2 = i + 2;
const i_3 = i + 3;
std.debug.print("R{}: 0x{X:0>8}\tR{}: 0x{X:0>8}\tR{}: 0x{X:0>8}\tR{}: 0x{X:0>8}\n", .{ i, self.r[i], i_1, self.r[i_1], i_2, self.r[i_2], i_3, self.r[i_3] });
} }
std.debug.print("cpsr: 0x{X:0>8}\tspsr: 0x{X:0>8}\n", .{ self.cpsr.raw, self.spsr.raw }); std.debug.print("cpsr: 0x{X:0>8} ", .{self.cpsr.raw});
prettyPrintPsr(&self.cpsr);
std.debug.print("spsr: 0x{X:0>8} ", .{self.spsr.raw});
prettyPrintPsr(&self.spsr);
std.debug.print("tick: {}\n\n", .{self.sched.tick}); std.debug.print("tick: {}\n\n", .{self.sched.tick});
std.debug.panic(format, args); std.debug.panic(format, args);
} }
fn prettyPrintPsr(psr: *PSR) void { fn prettyPrintPsr(psr: *const PSR) void {
std.debug.print("[", .{}); std.debug.print("[", .{});
if (psr.n.read()) std.debug.print("N", .{}) else std.debug.print("-", .{}); if (psr.n.read()) std.debug.print("N", .{}) else std.debug.print("-", .{});
@ -257,11 +265,23 @@ pub const Arm7tdmi = struct {
if (psr.v.read()) std.debug.print("V", .{}) else std.debug.print("-", .{}); if (psr.v.read()) std.debug.print("V", .{}) else std.debug.print("-", .{});
if (psr.i.read()) std.debug.print("I", .{}) else std.debug.print("-", .{}); if (psr.i.read()) std.debug.print("I", .{}) else std.debug.print("-", .{});
if (psr.f.read()) std.debug.print("F", .{}) else std.debug.print("-", .{}); if (psr.f.read()) std.debug.print("F", .{}) else std.debug.print("-", .{});
if (psr.T.read()) std.debug.print("T", .{}) else std.debug.print("-", .{}); if (psr.t.read()) std.debug.print("T", .{}) else std.debug.print("-", .{});
std.debug.print("|", .{}); std.debug.print("|", .{});
if (getMode(psr.mode.read())) |mode| std.debug.print("{}", mode) else std.debug.print("---"); if (getMode(psr.mode.read())) |mode| std.debug.print("{s}", .{modeString(mode)}) else std.debug.print("---", .{});
std.debug.print("]", .{}); std.debug.print("]\n", .{});
}
fn modeString(mode: Mode) []const u8 {
return switch (mode) {
.User => "usr",
.Fiq => "fiq",
.Irq => "irq",
.Supervisor => "svc",
.Abort => "abt",
.Undefined => "und",
.System => "sys",
};
} }
fn skyLog(self: *const Self, file: *const File) !void { fn skyLog(self: *const Self, file: *const File) !void {