1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-07-01 06:29:31 +00:00
rk65c02/src/emulation.c

77 lines
1.3 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
2017-01-20 21:38:46 +00:00
emul_pha(rk65c02emu_t *e, instruction_t *i)
2017-01-20 21:26:13 +00:00
{
stack_push(e, e->regs.A);
}
/* PLA - pull from stack to accumulator */
void
2017-01-20 21:38:46 +00:00
emul_pla(rk65c02emu_t *e, instruction_t *i)
2017-01-20 21:26:13 +00:00
{
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;
}
2017-01-21 20:46:35 +00:00
/* STZ - store zero */
void
emul_stz(rk65c02emu_t *e, instruction_t *i)
{
instrdef_t id;
id = instruction_decode(i->opcode);
instruction_data_write_1(e, &id, i, 0);
}