add float and int ==
This commit is contained in:
parent
d4d887e6a1
commit
4cb02c41d0
16
src/vm.c
16
src/vm.c
|
@ -105,6 +105,14 @@ void run_vm(Data *memory, uint32_t memory_size) {
|
|||
pc = (value < value2) ? jump_target : pc;
|
||||
break;
|
||||
}
|
||||
case OP_JEQ_REAL: {
|
||||
float value = memory[src1_addr].f;
|
||||
float value2 = memory[src2_addr].f;
|
||||
uint32_t jump_target = dest_addr;
|
||||
|
||||
pc = (value == value2) ? jump_target : pc;
|
||||
break;
|
||||
}
|
||||
case OP_JGT_REAL: {
|
||||
float value = memory[src1_addr].f;
|
||||
float value2 = memory[src2_addr].f;
|
||||
|
@ -121,6 +129,14 @@ void run_vm(Data *memory, uint32_t memory_size) {
|
|||
pc = (value < value2) ? jump_target : pc;
|
||||
break;
|
||||
}
|
||||
case OP_JEQ_INT: {
|
||||
uint32_t value = memory[src1_addr].u;
|
||||
uint32_t value2 = memory[src2_addr].u;
|
||||
uint32_t jump_target = dest_addr;
|
||||
|
||||
pc = (value == value2) ? jump_target : pc;
|
||||
break;
|
||||
}
|
||||
case OP_JGE_INT: {
|
||||
uint32_t value = memory[src1_addr].u;
|
||||
uint32_t value2 = memory[src2_addr].u;
|
||||
|
|
2
src/vm.h
2
src/vm.h
|
@ -15,6 +15,7 @@ typedef enum {
|
|||
OP_SUB, /* dest = src1 - src2 */
|
||||
OP_MUL, /* dest = src1 * src2 */
|
||||
OP_DIV, /* dest = src1 / src2 */
|
||||
OP_JEQ_INT, /* jump to address dest if src1 as int == src2 as int */
|
||||
OP_JGT_INT, /* jump to address dest if src1 as int > src2 as int*/
|
||||
OP_JLT_INT, /* jump to address dest if src1 as int < src2 as int */
|
||||
OP_JLE_INT, /* jump to address dest if src1 as int <= src2 as int */
|
||||
|
@ -24,6 +25,7 @@ typedef enum {
|
|||
OP_SUB_REAL, /* dest = src1 - src2 */
|
||||
OP_MUL_REAL, /* dest = src1 * src2 */
|
||||
OP_DIV_REAL, /* dest = src1 / src2 */
|
||||
OP_JEQ_REAL, /* jump to address dest if src1 as real == src2 as real */
|
||||
OP_JGE_REAL, /* jump to address dest if src1 as real >= src2 as real */
|
||||
OP_JGT_REAL, /* jump to address dest if src1 as real > src2 as real */
|
||||
OP_JLT_REAL, /* jump to address dest if src1 as real < src2 as real */
|
||||
|
|
Loading…
Reference in New Issue