Implement writing to memory
This commit is contained in:
parent
8d6f380f6b
commit
431377f92e
16
server.c
16
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue