summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-26 11:34:02 -0300
committerGabriel Schneider <[email protected]>2026-08-26 11:34:02 -0300
commit18a8e39c551e08eca9ed26e2c13580ccdd36b955 (patch)
treec4a616abe5b336f12f48d5cae16831d608b48e7a /src
parentfc7d3274c41ebc83911c5a6d1225cecea270cc86 (diff)
downloadpardes-18a8e39c551e08eca9ed26e2c13580ccdd36b955.tar.gz
pardes-18a8e39c551e08eca9ed26e2c13580ccdd36b955.zip
Drop the 0x from what Peek, Poke and Hexdump print
Two columns back, and a better reason than the two columns. Every number these words read is hex - there is no other kind, and they refuse a decimal one - so a prefix on the output restates what the whole file already says. Dropping it buys something worth more than the width: an address in a dump can be typed straight back into a Peek without editing it, because bare hex is exactly what the parser now wants. Output that is valid input beats output that is decorated. No platform question to answer either: `enabled` is freestanding-and-not-wasm, so these three words exist only on bare metal. There is no host format to stay consistent with. On the die, 44 columns of a 48-column body: 40000020 32 54 cd ab 00 00 00 00 |2T......| 40000030 30 2e 31 00 00 00 00 00 |0.1.....| 5011002c: wrote deadbeef, reads deadbeef 5011002c: deadbeef 501101a4: fc48777d 501101a4: 4b4ae238 The last two are the same command twice - LP_SYSTEM_REG_RNG_DATA, which is what makes it the honest demonstration that a register is not memory. unit-test, and `p4-bench --check` 4/4 on the board.
Diffstat (limited to 'src')
-rw-r--r--src/board_memory.zig12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/board_memory.zig b/src/board_memory.zig
index 702b130d..d2878d2d 100644
--- a/src/board_memory.zig
+++ b/src/board_memory.zig
@@ -264,7 +264,7 @@ pub fn peek(p: *Pardes, id: usize, argument: []const u8) !void {
try writeNote(&out.writer, e, requested, "words");
for (0..e.count) |i| {
const at = addr + @as(u32, @intCast(i * 4));
- try out.writer.print("0x{x:0>8}: 0x{x:0>8}\n", .{ at, readWord(at) });
+ try out.writer.print("{x:0>8}: {x:0>8}\n", .{ at, readWord(at) });
}
const content = try out.toOwnedSlice();
try fill(p, id, .{ .cmd = .Peek }, content);
@@ -291,7 +291,7 @@ pub fn poke(p: *Pardes, id: usize, argument: []const u8) !void {
var buf: [96]u8 = undefined;
p.setMessage(id, std.fmt.bufPrint(
&buf,
- "0x{x:0>8}: wrote 0x{x:0>8}, reads 0x{x:0>8}",
+ "{x:0>8}: wrote {x:0>8}, reads {x:0>8}",
.{ addr, value, back },
) catch unreachable);
}
@@ -306,6 +306,12 @@ pub fn poke(p: *Pardes, id: usize, argument: []const u8) !void {
/// Eight fits in 46 and keeps every property that matters: address on the left, fixed-width hex
/// columns, ASCII on the right, and a gap at the halfway mark because the eye counts in fours and
/// eights rather than in sixteens.
+///
+/// NO `0x` ON WHAT THESE WORDS PRINT, which is where two of those columns came from. It reads no
+/// worse - every number here is hex, there is no other kind, and the words refuse a decimal one - and
+/// it buys something better than the width: an address in a dump can now be typed straight back into
+/// a `Peek` without editing it, because bare hex is exactly what the parser wants. Output that is
+/// valid input is worth more than a prefix restating what the whole file already says.
const row_bytes: u32 = if (pardes.platform == .p4) 8 else 16;
/// `Hexdump <addr> [len]` — len bytes, `row_bytes` to a row, hex columns and an ASCII gutter, in
@@ -327,7 +333,7 @@ pub fn hexdump(p: *Pardes, id: usize, argument: []const u8) !void {
const n = @min(row_bytes, e.count - row);
var bytes: [row_bytes]u8 = undefined;
for (0..n) |i| bytes[i] = readByte(addr + row + @as(u32, @intCast(i)));
- try out.writer.print("0x{x:0>8} ", .{addr + row});
+ try out.writer.print("{x:0>8} ", .{addr + row});
for (0..row_bytes) |i| {
// The gap at the halfway mark: the eye counts to four or eight, not to sixteen.
if (i == row_bytes / 2) try out.writer.writeByte(' ');