cpu: fix dec_16
When getting the register index, an incorrect shift was being used. Fix the test case by correcting this. Signed-off-by: Max Regan <mgregan2@gmail.com>
This commit is contained in:
@@ -78,7 +78,6 @@ static void test_dec(const void *test_data)
|
|||||||
|
|
||||||
g_assert_cmpint(lr35902_get_reg_16(&cpu, LR35902_REG_DE), ==, 0xffff);
|
g_assert_cmpint(lr35902_get_reg_16(&cpu, LR35902_REG_DE), ==, 0xffff);
|
||||||
|
|
||||||
|
|
||||||
free(src);
|
free(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -734,10 +734,9 @@ static void ld_c_offset(struct lr35902_state *cpu, uint8_t instr)
|
|||||||
|
|
||||||
static void ld_hl_d16(struct lr35902_state *cpu, uint8_t inst)
|
static void ld_hl_d16(struct lr35902_state *cpu, uint8_t inst)
|
||||||
{
|
{
|
||||||
cpu->a = cpu->mem_read(cpu, cpu->hl++);
|
cpu->hl = _pop_stack_16(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void inc_16(struct lr35902_state *cpu, uint8_t instr)
|
static void inc_16(struct lr35902_state *cpu, uint8_t instr)
|
||||||
{
|
{
|
||||||
uint8_t reg;
|
uint8_t reg;
|
||||||
@@ -772,8 +771,11 @@ static void dec(struct lr35902_state *cpu, uint8_t instr)
|
|||||||
{
|
{
|
||||||
uint8_t reg = (instr >> 3) & 0x7;
|
uint8_t reg = (instr >> 3) & 0x7;
|
||||||
uint8_t val = _get_reg_8(cpu, reg);
|
uint8_t val = _get_reg_8(cpu, reg);
|
||||||
|
DEBUG_LOG("reg=%d, val=%d", reg, val);
|
||||||
val--;
|
val--;
|
||||||
|
DEBUG_LOG("val2=%d", val);
|
||||||
_set_reg_8(cpu, reg, val);
|
_set_reg_8(cpu, reg, val);
|
||||||
|
DEBUG_LOG("val3=%d", _get_reg_8(cpu, reg));
|
||||||
|
|
||||||
WRITE_BIT(cpu->f, LR35902_FLAG_BIT_Z, val == 0);
|
WRITE_BIT(cpu->f, LR35902_FLAG_BIT_Z, val == 0);
|
||||||
WRITE_BIT(cpu->f, LR35902_FLAG_BIT_N, 1);
|
WRITE_BIT(cpu->f, LR35902_FLAG_BIT_N, 1);
|
||||||
@@ -782,7 +784,7 @@ static void dec(struct lr35902_state *cpu, uint8_t instr)
|
|||||||
|
|
||||||
static void dec_16(struct lr35902_state *cpu, uint8_t instr)
|
static void dec_16(struct lr35902_state *cpu, uint8_t instr)
|
||||||
{
|
{
|
||||||
uint8_t reg = (instr & 0xF0) >> 8;
|
uint8_t reg = (instr & 0xF0) >> 4;
|
||||||
uint16_t val;
|
uint16_t val;
|
||||||
|
|
||||||
switch (reg) {
|
switch (reg) {
|
||||||
|
|||||||
Reference in New Issue
Block a user