Skip to content

Commit

Permalink
famiyirl: ADC absolute
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
cosmo-ray committed Apr 28, 2024
1 parent 56ae766 commit 93156e4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions modules/famiyirl/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,35 @@ static int process_inst(void)
goto out;
}
break;
case ADC_ab:
{
int addr = get_mem(++cpu.pc);
char old_sign = cpu.a & 0x80;

addr |= get_mem(++cpu.pc) << 8;
char res = get_mem(addr);
int check_carry = cpu.a + res;

cpu.a += res;
SET_CARY(check_carry > 255);
SET_OVERFLOW(old_sign != (cpu.a & 0x80));
SET_NEGATIVE(!!(0x80 & cpu.a));
SET_ZERO(!cpu.a);
cpu.cycle_cnt += 4;
}
break;
case ADC_im:
{
int addr = get_mem(++cpu.pc);
char old_sign = cpu.a & 0x80;

int check_carry = cpu.a + addr;

cpu.a += addr;
SET_CARY(check_carry > 255);
SET_OVERFLOW(old_sign != (cpu.a & 0x80));
SET_NEGATIVE(!!(0x80 & cpu.a));
SET_ZERO(!cpu.a);
cpu.cycle_cnt += 2;
}
break;
Expand Down
1 change: 1 addition & 0 deletions modules/famiyirl/opcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
OPCODE(ROR, 0x62) //rotate right
OPCODE(PLA, 0x68) //pull accumulator
OPCODE(ADC_im, 0x69) //add with carry
OPCODE(ADC_ab, 0x6D) //add with carry
OPCODE(BVS, 0x70) //branch on overflow set
OPCODE(SEI, 0x78) //set interrupt disable
OPCODE(STY, 0x80) //store Y
Expand Down

0 comments on commit 93156e4

Please sign in to comment.