From 14233cf3cac9d48052365c5137f91efd1035d799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kujawa?= Date: Fri, 20 Jan 2017 09:11:34 +0100 Subject: [PATCH] Implement status flags for LDA emulation. --- src/emulation.c | 10 ++++++++-- src/rk65c02.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/emulation.c b/src/emulation.c index fc090e6..c29c0dd 100644 --- a/src/emulation.c +++ b/src/emulation.c @@ -10,10 +10,16 @@ emul_lda(rk65c02emu_t *e, instruction_t *i) e->regs.A = instruction_data_read_1(e, &id, i); - /* adjust status flags */ + if (e->regs.A & NEGATIVE) + e->regs.P |= P_NEGATIVE; + else + e->regs.P &= ~P_NEGATIVE; - + if (e->regs.A == 0) + e->regs.P |= P_ZERO; + else + e->regs.P &= ~P_ZERO; } void diff --git a/src/rk65c02.h b/src/rk65c02.h index 95e7cce..6b0e698 100644 --- a/src/rk65c02.h +++ b/src/rk65c02.h @@ -28,6 +28,8 @@ struct reg_state { #define P_SIGN_OVERFLOW 0x40 #define P_NEGATIVE 0x80 +#define NEGATIVE P_NEGATIVE + typedef struct reg_state reg_state_t; struct rk65c02emu {