1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-10-01 09:57:47 +00:00
erc-c/src/mos6502.arith.c
2017-12-03 20:19:17 -06:00

68 lines
877 B
C

/*
* mos6502.inst.c
*/
#include "mos6502.h"
#include "mos6502.enums.h"
DEFINE_INST(adc)
{
CARRY_BIT();
cpu->A += oper + carry;
}
DEFINE_INST(cmp)
{
mos6502_modify_status(cpu, ZERO | NEGATIVE | CARRY, cpu->A - oper);
}
DEFINE_INST(cpx)
{
mos6502_modify_status(cpu, ZERO | NEGATIVE | CARRY, cpu->X - oper);
}
DEFINE_INST(cpy)
{
mos6502_modify_status(cpu, ZERO | NEGATIVE | CARRY, cpu->Y - oper);
}
DEFINE_INST(dec)
{
if (cpu->last_addr) {
vm_segment_set(cpu->memory, cpu->last_addr, oper - 1);
}
}
DEFINE_INST(dex)
{
cpu->X--;
}
DEFINE_INST(dey)
{
cpu->Y--;
}
DEFINE_INST(inc)
{
if (cpu->last_addr) {
vm_segment_set(cpu->memory, cpu->last_addr, oper + 1);
}
}
DEFINE_INST(inx)
{
cpu->X++;
}
DEFINE_INST(iny)
{
cpu->Y++;
}
DEFINE_INST(sbc)
{
CARRY_BIT();
cpu->A = cpu->A - oper - carry;
}