2017-01-18 14:45:28 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "emulation.h"
|
|
|
|
|
2017-01-20 21:26:13 +00:00
|
|
|
/* AND - logical AND */
|
2017-01-20 09:41:56 +00:00
|
|
|
void
|
|
|
|
emul_and(rk65c02emu_t *e, instruction_t *i)
|
|
|
|
{
|
|
|
|
instrdef_t id;
|
|
|
|
uint8_t rv;
|
|
|
|
|
2017-01-20 21:26:13 +00:00
|
|
|
id = instruction_decode(i->opcode);
|
|
|
|
|
2017-01-20 09:41:56 +00:00
|
|
|
rv = e->regs.A & (instruction_data_read_1(e, &id, i));
|
|
|
|
e->regs.A = rv;
|
|
|
|
|
|
|
|
instruction_status_adjust_zero(e, e->regs.A);
|
|
|
|
instruction_status_adjust_negative(e, e->regs.A);
|
|
|
|
}
|
|
|
|
|
2017-01-20 21:26:13 +00:00
|
|
|
/* LDA - load to accumulator */
|
2017-01-18 21:37:00 +00:00
|
|
|
void
|
|
|
|
emul_lda(rk65c02emu_t *e, instruction_t *i)
|
|
|
|
{
|
|
|
|
instrdef_t id;
|
2017-01-20 21:26:13 +00:00
|
|
|
|
2017-01-18 21:37:00 +00:00
|
|
|
id = instruction_decode(i->opcode);
|
|
|
|
|
2017-01-19 09:59:35 +00:00
|
|
|
e->regs.A = instruction_data_read_1(e, &id, i);
|
|
|
|
|
2017-01-20 09:41:56 +00:00
|
|
|
instruction_status_adjust_zero(e, e->regs.A);
|
|
|
|
instruction_status_adjust_negative(e, e->regs.A);
|
2017-01-18 21:37:00 +00:00
|
|
|
}
|
|
|
|
|
2017-01-20 21:26:13 +00:00
|
|
|
/* NOP - do nothing */
|
2017-01-18 14:45:28 +00:00
|
|
|
void
|
2017-01-18 16:18:19 +00:00
|
|
|
emul_nop(rk65c02emu_t *e, instruction_t *i)
|
2017-01-18 14:45:28 +00:00
|
|
|
{
|
2017-01-18 21:37:00 +00:00
|
|
|
/* printf("nop!\n"); */
|
2017-01-18 14:45:28 +00:00
|
|
|
}
|
|
|
|
|
2017-01-20 21:26:13 +00:00
|
|
|
/* PHA - push accumulator to stack */
|
|
|
|
void
|
|
|
|
emul_pha(rk6502emu_t *e, instruction_t *i)
|
|
|
|
{
|
|
|
|
stack_push(e, e->regs.A);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PLA - pull from stack to accumulator */
|
|
|
|
void
|
|
|
|
emul_pla(rk65c02emu_t *e, instruciton_t *i)
|
|
|
|
{
|
|
|
|
e->regs.A = stack_pop(e);
|
|
|
|
|
|
|
|
instruction_status_adjust_zero(e, e->regs.A);
|
|
|
|
instruction_status_adjust_negative(e, e->regs.A);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* STP - stop the processor */
|
2017-01-18 16:18:19 +00:00
|
|
|
void
|
|
|
|
emul_stp(rk65c02emu_t *e, instruction_t *i)
|
|
|
|
{
|
|
|
|
e->state = STOPPED;
|
|
|
|
}
|
2017-01-18 21:37:00 +00:00
|
|
|
|