From c74aea420c662039072f606b2d5ef1c73426e481 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Sat, 24 Aug 2024 14:29:55 +0300 Subject: Add more code Add some funcitons to work with variables, add more instructions and add ability to stop the code from `ccl_instruction` --- src/instruction/subtract.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/instruction/subtract.c (limited to 'src/instruction/subtract.c') 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; +} -- cgit 1.4.1