In stm8 use brackets for memory writes with mov ##arch

This commit is contained in:
pancake 2024-10-23 12:28:01 +02:00 committed by pancake
parent eb4b8d9f76
commit 14b495cc3f
4 changed files with 19 additions and 9 deletions

View File

@ -148,11 +148,11 @@ char *stm8_disasm(ut64 pc, const ut8 *data, int size, unsigned int *type, ut64 *
break;
case LONGMEM_34:
// ioreg
r_strbuf_appendf (sb, " 0x%02x%02x", oc[3], oc[4]);
r_strbuf_appendf (sb, " [0x%02x%02x]", oc[3], oc[4]);
break;
case LONGMEM_45:
// ioreg
r_strbuf_appendf (sb, " 0x%02x%02x", oc[4], oc[5]);
r_strbuf_appendf (sb, " [0x%02x%02x]", oc[4], oc[5]);
break;
case EXTMEM_234:
r_strbuf_appendf (sb, " 0x%02x%02x%02x", oc[2], oc[3], oc[4]);
@ -273,7 +273,7 @@ char *stm8_disasm(ut64 pc, const ut8 *data, int size, unsigned int *type, ut64 *
r_strbuf_appendf (sb, ", 0x%02x", oc[2]);
break;
case SHORTMEM_3:
r_strbuf_appendf (sb, ", 0x%02x", oc[3]);
r_strbuf_appendf (sb, ", [0x%02x]", oc[3]);
break;
case LONGMEM_23:
r_strbuf_appendf (sb, ", 0x%02x%02x", oc[2], oc[3]);

View File

@ -27,7 +27,7 @@ static int replace(int argc, const char *argv[], char *newstr) {
{ 0, "dec", "[#] --", { 1 } },
{ 0, "ret", "return;", {}},
{ 0, "iret", "return;", {}},
{ 2, "mov", "[#] = #", { 1, 2 } }, // MOVS are stores
{ 2, "mov", "# = #", { 1, 2 } }, // MOVS are stores
{ 2, "mul", "# *= #", { 1, 2 } },
{ 1, "neg", "# = !#", { 1, 1 } }, // TODO carry = (res != 0)
{ 2, "divw", "# /= #", { 1, 2 } },

View File

@ -1275,14 +1275,14 @@ static void cmd_Cv(RCore *core, const char *input) {
}
if (var) {
if (var->comment) {
if (comment && *comment) {
if (R_STR_ISNOTEMPTY (comment)) {
char *text = r_str_newf ("%s\n%s", var->comment, comment);
free (var->comment);
var->comment = text;
} else {
r_cons_println (var->comment);
}
} else {
} else if (R_STR_ISNOTEMPTY (comment)) {
var->comment = strdup (comment);
}
} else {

View File

@ -214,9 +214,12 @@ static void rprj_entry_end(RBuffer *b, ut64 at) {
}
static bool rprj_string_read(RBuffer *b, char **s) {
ut8 buf[sizeof (ut32)];
ut8 buf[sizeof (ut32)] = {0};
r_buf_read (b, buf, sizeof (buf));
size_t len = r_read_le32 (buf);
int len = r_read_le32 (buf);
if (len < 1) {
return false;
}
ut8 *data = malloc (len + 1);
*s = NULL;
if (R_LIKELY (data)) {
@ -268,6 +271,9 @@ static bool rprj_mods_read(RBuffer *b, R2ProjectMod *mod) {
static void rprj_mods_write_one(RBuffer *b, R2ProjectMod *mod) {
ut8 buf[sizeof (R2ProjectMod)];
ut64 at = r_buf_at (b);
if (at > UT32_MAX) {
return;
}
r_write_le32 (buf + r_offsetof (R2ProjectMod, name), mod->name);
r_write_le32 (buf + r_offsetof (R2ProjectMod, file), mod->file);
r_write_le64 (buf + r_offsetof (R2ProjectMod, pmin), mod->pmin);
@ -427,11 +433,15 @@ static ut8 *rprj_find(RBuffer *b, ut32 type, ut32 *size) {
ut64 at = r_buf_at (b);
*size = 0;
while (r_buf_at (b) < last) {
R2ProjectEntry entry;
R2ProjectEntry entry = {0};
if (!rprj_entry_read (b, &entry)) {
R_LOG_ERROR ("find: Cannot read entry");
break;
}
if (entry.size > ST32_MAX) {
R_LOG_ERROR ("invalid size");
break;
}
if (entry.type == type) {
ut8 *buf = malloc (entry.size);
if (buf) {