update docs, fix float jmp

This commit is contained in:
zongor 2025-06-22 10:57:15 -04:00
parent 457c77b6ab
commit a741a0c992
3 changed files with 11 additions and 11 deletions

View File

@ -31,7 +31,7 @@
** Language Design ** Language Design
- Strongly typed but with a friendly 'let' syntax. - Strongly typed but with a friendly 'let' syntax.
- =real= type (fixed point Q16.16 by default). - =real= type (f32).
- =int= for integer numbers (i32). - =int= for integer numbers (i32).
- =nat= for unsigned integer numbers (u32). - =nat= for unsigned integer numbers (u32).
- =byte= for interop (u8, i64, etc.). - =byte= for interop (u8, i64, etc.).

View File

@ -19,12 +19,12 @@ typedef struct {
typedef enum { typedef enum {
OP_HALT, /* terminate execution */ OP_HALT, /* terminate execution */
OP_LOADI, /* loads an int from memory */ OP_LOADI, /* dest = next memory location as int */
OP_LOADU, /* loads a uint from memory */ OP_LOADU, /* dest = next memory location as uint */
OP_LOADF, /* loads a float from memory */ OP_LOADF, /* dest = next memory location as float */
OP_STOREI, /* stores a int to memory */ OP_STOREI, /* next memory location = src1 as int */
OP_STOREU, /* stores a uint to memory */ OP_STOREU, /* next memory location = src1 as uint */
OP_STOREF, /* stores a float to memory */ OP_STOREF, /* next memory location = src1 as float */
OP_ADD_INT, /* dest = src1 + src2 */ OP_ADD_INT, /* dest = src1 + src2 */
OP_SUB_INT, /* dest = src1 - src2 */ OP_SUB_INT, /* dest = src1 - src2 */
OP_MUL_INT, /* dest = src1 * src2 */ OP_MUL_INT, /* dest = src1 * src2 */

View File

@ -139,16 +139,16 @@ uint32_t step_vm(VMFrame *frame, Value *memory) {
COMPARE_AND_JUMP(int32_t, i, ==); COMPARE_AND_JUMP(int32_t, i, ==);
} }
case OP_JGT_REAL: { case OP_JGT_REAL: {
COMPARE_AND_JUMP(int32_t, u, >); COMPARE_AND_JUMP(float, u, >);
} }
case OP_JLT_REAL: { case OP_JLT_REAL: {
COMPARE_AND_JUMP(int32_t, u, <); COMPARE_AND_JUMP(float, u, <);
} }
case OP_JGE_REAL: { case OP_JGE_REAL: {
COMPARE_AND_JUMP(int32_t, u, >=); COMPARE_AND_JUMP(float, u, >=);
} }
case OP_JLE_REAL: { case OP_JLE_REAL: {
COMPARE_AND_JUMP(int32_t, u, <=); COMPARE_AND_JUMP(float, u, <=);
} }
case OP_INT_TO_STRING: { case OP_INT_TO_STRING: {
int32_t a = (int32_t)frame->registers[src1].i; int32_t a = (int32_t)frame->registers[src1].i;