1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-11-18 22:06:01 +00:00
erc-c/src/mos6502.arith.c

68 lines
877 B
C
Raw Normal View History

2017-12-02 19:05:53 +00:00
/*
* 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();
2017-12-04 02:19:17 +00:00
cpu->A = cpu->A - oper - carry;
2017-12-02 19:05:53 +00:00
}