xor di and cpu flags

This commit is contained in:
2025-01-30 18:38:29 -07:00
parent 6a82e9fa03
commit 1bf98447a3
6 changed files with 38 additions and 9 deletions

View File

@ -12,6 +12,30 @@ static void proc_nop(cpu_context *ctx) {
}
void cpu_set_flags(cpu_context *ctx, u8 z, u8 n, u8 h, u8 c){
if (z != -1){
BIT_SET(ctx->regs.f, 7, z)
}
if (n != -1){
BIT_SET(ctx->regs.f, 6, n)
}
if (h != -1){
BIT_SET(ctx->regs.f, 5, h)
}
if (c != -1){
BIT_SET(ctx->regs.f, 4, c)
}
}
static void proc_xor(cpu_context *ctx) {
ctx->regs.a ^= ctx->fetched_data & 0XFF;
cpu_set_flags(ctx, ctx->regs.a == 0, 0, 0, 0);
}
static void proc_di(cpu_context *ctx) {
ctx->int_master_enabled = false;
}
static void proc_ld(cpu_context *ctx) {
//TODO
}
@ -43,6 +67,8 @@ IN_PROC processors[] = {
[IN_NOP] = proc_nop,
[IN_LD] = proc_ld,
[IN_JP] = proc_jp,
[IN_DI] = proc_di,
[IN_XOR] = proc_xor
};
IN_PROC inst_get_processor(in_type type) {