1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-10-01 09:57:06 +00:00
rk65c02/src/emulation.c

66 lines
1.2 KiB
C
Raw Normal View History

#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 */
void
emul_lda(rk65c02emu_t *e, instruction_t *i)
{
instrdef_t id;
2017-01-20 21:26:13 +00:00
id = instruction_decode(i->opcode);
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-20 21:26:13 +00:00
/* NOP - do nothing */
void
emul_nop(rk65c02emu_t *e, instruction_t *i)
{
/* printf("nop!\n"); */
}
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 */
void
emul_stp(rk65c02emu_t *e, instruction_t *i)
{
e->state = STOPPED;
}