From 300e0fb25832b14af0bc7dedd5d6cc168b8cf599 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 24 Nov 2023 19:07:43 +0100 Subject: [PATCH] Added pop and jp --- include/ulas.h | 1 + src/ulas.c | 13 +++++++++++++ test/t0.s | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/include/ulas.h b/include/ulas.h index a64158e..412bebd 100644 --- a/include/ulas.h +++ b/include/ulas.h @@ -316,6 +316,7 @@ enum ulas_asmregs { ULAS_REG_BC = 8, ULAS_REG_DE = 9, ULAS_REG_HL = 10, + ULAS_REG_AF = 16, // flags ULAS_REG_NOT_ZERO = 11, diff --git a/src/ulas.c b/src/ulas.c index ceebeec..4577502 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -1384,6 +1384,8 @@ const char *ulas_asmregstr(enum ulas_asmregs reg) { return "c"; case ULAS_REG_SP: return "sp"; + case ULAS_REG_AF: + return "af"; } return NULL; @@ -1531,6 +1533,11 @@ const struct ulas_instr ULASINSTRS[] = { ULAS_INSTR_REG("ret", 0xC0, ULAS_REG_NOT_ZERO), ULAS_INSTR_REG("ret", 0xD0, ULAS_REG_NOT_CARRY), + // jp + ULAS_INSTR_R16E16("jp", 0xC2, ULAS_REG_NOT_ZERO), + ULAS_INSTR_R16E16("jp", 0xD2, ULAS_REG_NOT_CARRY), + {"jp", {ULAS_E16, 0}, {0xC3, ULAS_E16, 0x00}}, + // inc/dec ULAS_INSTR_REG("inc", 0x03, ULAS_REG_BC), ULAS_INSTR_REG("inc", 0x13, ULAS_REG_DE), @@ -1578,6 +1585,12 @@ const struct ulas_instr ULASINSTRS[] = { ULAS_INSTR_R16R16("add", 0x29, ULAS_REG_HL, ULAS_REG_HL), ULAS_INSTR_R16R16("add", 0x39, ULAS_REG_HL, ULAS_REG_SP), + // pop + ULAS_INSTR_REG("pop", 0xC1, ULAS_REG_BC), + ULAS_INSTR_REG("pop", 0xD1, ULAS_REG_DE), + ULAS_INSTR_REG("pop", 0xE1, ULAS_REG_HL), + ULAS_INSTR_REG("pop", 0xF1, ULAS_REG_AF), + {NULL}}; // assembles an instruction, writes bytes into dst diff --git a/test/t0.s b/test/t0.s index e792dbb..49865ea 100644 --- a/test/t0.s +++ b/test/t0.s @@ -41,3 +41,8 @@ ld [1], a ld a, [2] + + pop bc + jp nz, 2 + + jp 3 -- 2.30.2