From a741a0c992808021fcf3bf489f30d60110b48f6c Mon Sep 17 00:00:00 2001 From: zongor Date: Sun, 22 Jun 2025 10:57:15 -0400 Subject: [PATCH] update docs, fix float jmp --- README.org | 2 +- src/opcodes.h | 12 ++++++------ src/vm.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.org b/README.org index 59f9fa9..fe523d2 100644 --- a/README.org +++ b/README.org @@ -31,7 +31,7 @@ ** Language Design - Strongly typed but with a friendly 'let' syntax. - - =real= type (fixed point Q16.16 by default). + - =real= type (f32). - =int= for integer numbers (i32). - =nat= for unsigned integer numbers (u32). - =byte= for interop (u8, i64, etc.). diff --git a/src/opcodes.h b/src/opcodes.h index e56206c..34a7828 100644 --- a/src/opcodes.h +++ b/src/opcodes.h @@ -19,12 +19,12 @@ typedef struct { typedef enum { OP_HALT, /* terminate execution */ - OP_LOADI, /* loads an int from memory */ - OP_LOADU, /* loads a uint from memory */ - OP_LOADF, /* loads a float from memory */ - OP_STOREI, /* stores a int to memory */ - OP_STOREU, /* stores a uint to memory */ - OP_STOREF, /* stores a float to memory */ + OP_LOADI, /* dest = next memory location as int */ + OP_LOADU, /* dest = next memory location as uint */ + OP_LOADF, /* dest = next memory location as float */ + OP_STOREI, /* next memory location = src1 as int */ + OP_STOREU, /* next memory location = src1 as uint */ + OP_STOREF, /* next memory location = src1 as float */ OP_ADD_INT, /* dest = src1 + src2 */ OP_SUB_INT, /* dest = src1 - src2 */ OP_MUL_INT, /* dest = src1 * src2 */ diff --git a/src/vm.c b/src/vm.c index 4bbf238..7e1a2de 100644 --- a/src/vm.c +++ b/src/vm.c @@ -139,16 +139,16 @@ uint32_t step_vm(VMFrame *frame, Value *memory) { COMPARE_AND_JUMP(int32_t, i, ==); } case OP_JGT_REAL: { - COMPARE_AND_JUMP(int32_t, u, >); + COMPARE_AND_JUMP(float, u, >); } case OP_JLT_REAL: { - COMPARE_AND_JUMP(int32_t, u, <); + COMPARE_AND_JUMP(float, u, <); } case OP_JGE_REAL: { - COMPARE_AND_JUMP(int32_t, u, >=); + COMPARE_AND_JUMP(float, u, >=); } case OP_JLE_REAL: { - COMPARE_AND_JUMP(int32_t, u, <=); + COMPARE_AND_JUMP(float, u, <=); } case OP_INT_TO_STRING: { int32_t a = (int32_t)frame->registers[src1].i;