LR35902: Fix trailing whitespace in disassembly

This commit is contained in:
Vicki Pfau 2019-04-29 12:16:41 -07:00
parent 029638ae99
commit 0de37f30b6
2 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -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);