feat: implement memory writes
This commit is contained in:
parent
82bad92fcf
commit
81ff227ea7
|
@ -95,7 +95,28 @@ pub fn parse(self: *Self, allocator: Allocator, emu: *Emulator) !String {
|
||||||
|
|
||||||
return .{ .alloc = ret };
|
return .{ .alloc = ret };
|
||||||
},
|
},
|
||||||
'M' => @panic("TODO: Memory Write"),
|
'M' => {
|
||||||
|
var tokens = std.mem.tokenize(u8, self.contents[1..], ",:");
|
||||||
|
|
||||||
|
const addr_str = tokens.next() orelse return error.InvalidPacket;
|
||||||
|
const length_str = tokens.next() orelse return error.InvalidPacket;
|
||||||
|
const bytes = tokens.next() orelse return error.InvalidPacket;
|
||||||
|
|
||||||
|
const addr = try std.fmt.parseInt(u32, addr_str, 16);
|
||||||
|
const len = try std.fmt.parseInt(u32, length_str, 16);
|
||||||
|
|
||||||
|
{
|
||||||
|
var i: u32 = 0;
|
||||||
|
while (i < len) : (i += 1) {
|
||||||
|
const str = bytes[2 * i ..][0..2];
|
||||||
|
const value = try std.fmt.parseInt(u8, str, 16);
|
||||||
|
|
||||||
|
emu.write(addr + i, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return .{ .static = "OK" };
|
||||||
|
},
|
||||||
'c' => {
|
'c' => {
|
||||||
switch (emu.contd()) {
|
switch (emu.contd()) {
|
||||||
.SingleStep => unreachable,
|
.SingleStep => unreachable,
|
||||||
|
@ -160,18 +181,17 @@ pub fn parse(self: *Self, allocator: Allocator, emu: *Emulator) !String {
|
||||||
else => return .{ .static = "" },
|
else => return .{ .static = "" },
|
||||||
},
|
},
|
||||||
|
|
||||||
// Optional
|
// TODO: Figure out the difference between 'M' and 'X'
|
||||||
'D' => {
|
'D' => {
|
||||||
log.info("Disconnecting...", .{});
|
log.info("Disconnecting...", .{});
|
||||||
return .{ .static = "OK" };
|
return .{ .static = "OK" };
|
||||||
},
|
},
|
||||||
'H' => return .{ .static = "" },
|
'H' => return .{ .static = "" },
|
||||||
'v' => {
|
'v' => {
|
||||||
if (substr(self.contents[1..], "MustReplyEmpty")) {
|
if (!substr(self.contents[1..], "MustReplyEmpty")) {
|
||||||
return .{ .static = "" };
|
log.warn("Unimplemented: {s}", .{self.contents});
|
||||||
}
|
}
|
||||||
|
|
||||||
log.warn("Unimplemented: {s}", .{self.contents});
|
|
||||||
return .{ .static = "" };
|
return .{ .static = "" };
|
||||||
},
|
},
|
||||||
'q' => {
|
'q' => {
|
||||||
|
|
Loading…
Reference in New Issue