summary refs log tree commit diff
path: root/src/instruction/subtract.c
diff options
context:
space:
mode:
authorNakidai <plaza521@inbox.ru>2024-08-24 14:29:55 +0300
committerNakidai <plaza521@inbox.ru>2024-08-24 14:29:55 +0300
commitc74aea420c662039072f606b2d5ef1c73426e481 (patch)
tree4790fa17644df9e11380d6c02b8928c923c20aba /src/instruction/subtract.c
parent2b0e05cbc1e4d9beccd3a5867c8730880f6ecc10 (diff)
download3cl-c74aea420c662039072f606b2d5ef1c73426e481.tar.gz
3cl-c74aea420c662039072f606b2d5ef1c73426e481.zip
Add more code
Add some funcitons to work with variables, add more instructions and add
ability to stop the code from `ccl_instruction`
Diffstat (limited to 'src/instruction/subtract.c')
-rw-r--r--src/instruction/subtract.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/instruction/subtract.c b/src/instruction/subtract.c
new file mode 100644
index 0000000..f140cfb
--- /dev/null
+++ b/src/instruction/subtract.c
@@ -0,0 +1,12 @@
+#include "3cl.h"
+
+#include "stack.h"
+#include "utils.h"
+
+struct CCLFrame *ccl_instruction_subtract(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;
+}