diff options
| author | Nakidai <plaza521@inbox.ru> | 2024-08-23 20:43:31 +0300 |
|---|---|---|
| committer | Nakidai <plaza521@inbox.ru> | 2024-08-23 20:43:31 +0300 |
| commit | 2b0e05cbc1e4d9beccd3a5867c8730880f6ecc10 (patch) | |
| tree | f0e5e31e6259e0b6ea940c1d4c394b976a4bac74 /src/instruction | |
| parent | 9e4058194742794f7742f19cb1a0bb3451ce22ea (diff) | |
| download | 3cl-2b0e05cbc1e4d9beccd3a5867c8730880f6ecc10.tar.gz 3cl-2b0e05cbc1e4d9beccd3a5867c8730880f6ecc10.zip | |
Start to rewriting code
Since there's some UB in the master I decided to rewrite code from scratch again. I hope that attempt will be better :D
Diffstat (limited to 'src/instruction')
| -rw-r--r-- | src/instruction/decrement.c | 8 | ||||
| -rw-r--r-- | src/instruction/increment.c | 8 | ||||
| -rw-r--r-- | src/instruction/nop.c | 7 | ||||
| -rw-r--r-- | src/instruction/pushzero.c | 10 |
4 files changed, 33 insertions, 0 deletions
diff --git a/src/instruction/decrement.c b/src/instruction/decrement.c new file mode 100644 index 0000000..f7f54dd --- /dev/null +++ b/src/instruction/decrement.c @@ -0,0 +1,8 @@ +#include "3cl.h" +#include "instruction.h" + +struct CCLFrame *ccl_instruction_decrement(struct CCL *ccl, struct CCLFrame *frame) +{ + --ccl->stack.stack[ccl->stack.cur]; + return frame; +} diff --git a/src/instruction/increment.c b/src/instruction/increment.c new file mode 100644 index 0000000..51697f1 --- /dev/null +++ b/src/instruction/increment.c @@ -0,0 +1,8 @@ +#include "3cl.h" +#include "instruction.h" + +struct CCLFrame *ccl_instruction_increment(struct CCL *ccl, struct CCLFrame *frame) +{ + ++ccl->stack.stack[ccl->stack.cur]; + return frame; +} diff --git a/src/instruction/nop.c b/src/instruction/nop.c new file mode 100644 index 0000000..8e05396 --- /dev/null +++ b/src/instruction/nop.c @@ -0,0 +1,7 @@ +#include "3cl.h" +#include "instruction.h" + +struct CCLFrame *ccl_instruction_nop(struct CCL *ccl, struct CCLFrame *frame) +{ + return frame; +} diff --git a/src/instruction/pushzero.c b/src/instruction/pushzero.c new file mode 100644 index 0000000..ef380cd --- /dev/null +++ b/src/instruction/pushzero.c @@ -0,0 +1,10 @@ +#include "3cl.h" +#include "instruction.h" + +#include "stack.h" + +struct CCLFrame *ccl_instruction_pushzero(struct CCL *ccl, struct CCLFrame *frame) +{ + ccl_stack_push(&ccl->stack, 0); + return frame; +} |