aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-06-18 11:27:04 +0200
committerkdx <kikoodx@paranoici.org>2023-06-18 11:27:12 +0200
commitb26dbd00d0783d3fb2b73410b2afa2ce5d40adea (patch)
tree25e92aa23eaf868b4b40dcc33c7288bf69ebd2e4
parent762808190ed93824ba3e4139a153ebf0699bb3f8 (diff)
downloadorga-b26dbd00d0783d3fb2b73410b2afa2ce5d40adea.tar.gz
MODulo instruction
-rw-r--r--src/ops.h2
-rw-r--r--src/orgaemu.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/src/ops.h b/src/ops.h
index e42656f..47e4862 100644
--- a/src/ops.h
+++ b/src/ops.h
@@ -28,6 +28,7 @@ enum {
OP_SUB,
OP_MUL,
OP_DIV,
+ OP_MOD,
OP_AND,
OP_ORA,
OP_XOR,
@@ -67,6 +68,7 @@ static const char ops[][4] = {
[OP_SUB] = "SUB",
[OP_MUL] = "MUL",
[OP_DIV] = "DIV",
+ [OP_MOD] = "MOD",
[OP_AND] = "AND",
[OP_ORA] = "ORA",
[OP_XOR] = "XOR",
diff --git a/src/orgaemu.c b/src/orgaemu.c
index e08199b..e57601d 100644
--- a/src/orgaemu.c
+++ b/src/orgaemu.c
@@ -329,6 +329,12 @@ exec_op(uint16_t *mem, long pc)
push(a / b);
return pc + 1;
}
+ case OP_MOD: {
+ const uint16_t b = pop();
+ const uint16_t a = pop();
+ push(a % b);
+ return pc + 1;
+ }
case OP_AND:
push(pop() & pop());
return pc + 1;