mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-24 14:32:08 +00:00
68 lines
877 B
C
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;
|
|
}
|