about summary refs log tree commit diff
path: root/src/instruction/add.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/instruction/add.c')
-rw-r--r--src/instruction/add.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/instruction/add.c b/src/instruction/add.c
new file mode 100644
index 0000000..81bef71
--- /dev/null
+++ b/src/instruction/add.c
@@ -0,0 +1,14 @@
+#include "3cl.h"
+
+#include "readchar.h"
+#include "stack.h"
+#include "utils.h"
+
+struct CCLFrame *ccl_instruction_add(struct CCL *ccl, struct CCLFrame *frame)
+{
+    if (ccl->stack.cur < 2)
+        die(1, "stack size is %d (%d required)", ccl->stack.cur, 2);
+    ccl_stack_push(&ccl->stack, ccl_stack_pop(&ccl->stack) + ccl_stack_pop(&ccl->stack));
+
+    return frame;
+}