mirror of https://github.com/mgba-emu/mgba.git
LR35902: Fix decoding LD r, $imm and 0-valued immediates (fixes #735)
This commit is contained in:
parent
96ac375276
commit
5031ef7c39
1
CHANGES
1
CHANGES
|
@ -56,6 +56,7 @@ Bugfixes:
|
||||||
- GBA Hardware: Fix crash if a savestate lies about game hardware
|
- GBA Hardware: Fix crash if a savestate lies about game hardware
|
||||||
- Test: Fix crash when fuzzing fails to load a file
|
- Test: Fix crash when fuzzing fails to load a file
|
||||||
- Qt: Disable "New multiplayer window" when MAX_GBAS is reached (fixes mgba.io/i/107)
|
- Qt: Disable "New multiplayer window" when MAX_GBAS is reached (fixes mgba.io/i/107)
|
||||||
|
- LR35902: Fix decoding LD r, $imm and 0-valued immediates (fixes mgba.io/i/735)
|
||||||
Misc:
|
Misc:
|
||||||
- SDL: Remove scancode key input
|
- SDL: Remove scancode key input
|
||||||
- GBA Video: Clean up unused timers
|
- GBA Video: Clean up unused timers
|
||||||
|
|
|
@ -66,8 +66,7 @@ DEFINE_DECODER_LR35902(NOP, info->mnemonic = LR35902_MN_NOP;)
|
||||||
DEFINE_LD_DECODER_LR35902_MEM(NAME, HL) \
|
DEFINE_LD_DECODER_LR35902_MEM(NAME, HL) \
|
||||||
DEFINE_LD_DECODER_LR35902_MEM_2(NAME, HL) \
|
DEFINE_LD_DECODER_LR35902_MEM_2(NAME, HL) \
|
||||||
DEFINE_DECODER_LR35902(LD ## NAME ## _, info->mnemonic = LR35902_MN_LD; \
|
DEFINE_DECODER_LR35902(LD ## NAME ## _, info->mnemonic = LR35902_MN_LD; \
|
||||||
info->op1.reg = LR35902_REG_A; \
|
info->op1.reg = LR35902_REG_ ## NAME; \
|
||||||
info->op1.flags = LR35902_OP_FLAG_IMPLICIT; \
|
|
||||||
return 1;) \
|
return 1;) \
|
||||||
DEFINE_LD_DECODER_LR35902_NOHL(NAME)
|
DEFINE_LD_DECODER_LR35902_NOHL(NAME)
|
||||||
|
|
||||||
|
@ -500,7 +499,10 @@ static int _decodeOperand(struct LR35902Operand op, char* buffer, int blen) {
|
||||||
strncpy(buffer, "(", blen - 1);
|
strncpy(buffer, "(", blen - 1);
|
||||||
ADVANCE(1);
|
ADVANCE(1);
|
||||||
}
|
}
|
||||||
if (op.immediate) {
|
if (op.reg) {
|
||||||
|
int written = snprintf(buffer, blen - 1, "%s", _lr35902Registers[op.reg]);
|
||||||
|
ADVANCE(written);
|
||||||
|
} else {
|
||||||
int written = snprintf(buffer, blen - 1, "$%02X", op.immediate);
|
int written = snprintf(buffer, blen - 1, "$%02X", op.immediate);
|
||||||
ADVANCE(written);
|
ADVANCE(written);
|
||||||
if (op.reg) {
|
if (op.reg) {
|
||||||
|
@ -508,10 +510,6 @@ static int _decodeOperand(struct LR35902Operand op, char* buffer, int blen) {
|
||||||
ADVANCE(1);
|
ADVANCE(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (op.reg) {
|
|
||||||
int written = snprintf(buffer, blen - 1, "%s", _lr35902Registers[op.reg]);
|
|
||||||
ADVANCE(written);
|
|
||||||
}
|
|
||||||
if (op.flags & LR35902_OP_FLAG_INCREMENT) {
|
if (op.flags & LR35902_OP_FLAG_INCREMENT) {
|
||||||
strncpy(buffer, "+", blen - 1);
|
strncpy(buffer, "+", blen - 1);
|
||||||
ADVANCE(1);
|
ADVANCE(1);
|
||||||
|
@ -546,10 +544,12 @@ int LR35902Disassemble(struct LR35902InstructionInfo* info, char* buffer, int bl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
written = _decodeOperand(info->op1, buffer, blen);
|
if (info->op1.reg || info->op1.immediate) {
|
||||||
ADVANCE(written);
|
written = _decodeOperand(info->op1, buffer, blen);
|
||||||
|
ADVANCE(written);
|
||||||
|
}
|
||||||
|
|
||||||
if (info->op2.reg || info->op2.immediate) {
|
if (info->op2.reg || (!info->op1.immediate && info->opcodeSize > 1 && info->opcode[0] != 0xCB)) {
|
||||||
if (written) {
|
if (written) {
|
||||||
strncpy(buffer, ", ", blen - 1);
|
strncpy(buffer, ", ", blen - 1);
|
||||||
ADVANCE(2);
|
ADVANCE(2);
|
||||||
|
|
Loading…
Reference in New Issue