Implement writing to memory

This commit is contained in:
Simon Gellis 2024-10-09 23:25:43 -04:00
parent 8d6f380f6b
commit 431377f92e
1 changed files with 16 additions and 0 deletions

View File

@ -223,6 +223,22 @@ int handle_command(RdbResponse *res, CommandBuf *cmd, VB *sim, bool *running) {
}
return rdb_response_send_packet(res);
}
if (cmd_match_str(cmd, "M")) {
/* write memory */
uint32_t i, address, len;
if (!cmd_match_hex_number(cmd, &address)) return -1;
if (!cmd_match_str(cmd, ",")) return -1;
if (!cmd_match_hex_number(cmd, &len)) return -1;
if (!cmd_match_str(cmd, ":")) return -1;
for (i = 0; i < len; ++i) {
uint8_t byte;
if (!cmd_match_hex_bytes(cmd, 1, &byte)) return -1;
vbWrite(sim, address + i, VB_U8, byte);
}
rdb_response_write_str(res, "OK");
return rdb_response_send_packet(res);
}
fprintf(stderr, "Unrecognized command.\n");
return rdb_response_send_packet(res);
}