diff --git a/CHANGES b/CHANGES index fa3880911..fbf490aca 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,7 @@ Other fixes: - 3DS: Ensure core 2 can be used for threaded renderer (fixes mgba.io/i/1371) - GB Core: Fix toggling WIN and OBJ being swapped - All: Fix several memory leaks + - LR35902: Fix trailing whitespace in disassembly Misc: - Qt: Add missing HEVC NVENC option (fixes mgba.io/i/1323) - Qt: Improve camera initialization diff --git a/src/lr35902/decoder.c b/src/lr35902/decoder.c index 76c6b9f02..2a7932a14 100644 --- a/src/lr35902/decoder.c +++ b/src/lr35902/decoder.c @@ -503,6 +503,9 @@ static int _decodeOperand(struct LR35902Operand op, char* buffer, int blen) { return 0; } + strncpy(buffer, " ", blen - 1); + ADVANCE(1); + if (op.flags & LR35902_OP_FLAG_MEMORY) { strncpy(buffer, "[", blen - 1); ADVANCE(1); @@ -539,16 +542,16 @@ int LR35902Disassemble(struct LR35902InstructionInfo* info, char* buffer, int bl int total = 0; const char* cond = _lr35902Conditions[info->condition]; - written = snprintf(buffer, blen - 1, "%s ", mnemonic); + written = snprintf(buffer, blen - 1, "%s", mnemonic); ADVANCE(written); if (cond) { - written = snprintf(buffer, blen - 1, "%s", cond); + written = snprintf(buffer, blen - 1, " %s", cond); ADVANCE(written); if (info->op1.reg || info->op1.immediate || info->op2.reg || info->op2.immediate) { - strncpy(buffer, ", ", blen - 1); - ADVANCE(2); + strncpy(buffer, ",", blen - 1); + ADVANCE(1); } } @@ -559,8 +562,8 @@ int LR35902Disassemble(struct LR35902InstructionInfo* info, char* buffer, int bl if (info->op2.reg || (!info->op1.immediate && info->opcodeSize > 1 && info->opcode[0] != 0xCB)) { if (written) { - strncpy(buffer, ", ", blen - 1); - ADVANCE(2); + strncpy(buffer, ",", blen - 1); + ADVANCE(1); } written = _decodeOperand(info->op2, buffer, blen); ADVANCE(written);