diff --git a/server.c b/server.c index c4792af..03e104e 100644 --- a/server.c +++ b/server.c @@ -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); }