Implemented vm routines for OP_NOT_*
This commit is contained in:
@@ -335,3 +335,34 @@ data_t vm_pop_word(vm_t *vm)
|
|||||||
}
|
}
|
||||||
return DWORD(w);
|
return DWORD(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vm_not_byte(vm_t *vm)
|
||||||
|
{
|
||||||
|
if (vm->stack.ptr == 0)
|
||||||
|
// TODO: Error STACK_UNDERFLOW
|
||||||
|
return;
|
||||||
|
|
||||||
|
byte a = vm_pop_byte(vm).as_byte;
|
||||||
|
vm_push_byte(vm, DBYTE(!a));
|
||||||
|
}
|
||||||
|
|
||||||
|
void vm_not_hword(vm_t *vm)
|
||||||
|
{
|
||||||
|
if (vm->stack.ptr < HWORD_SIZE)
|
||||||
|
// TODO: Error STACK_UNDERFLOW
|
||||||
|
return;
|
||||||
|
|
||||||
|
hword a = vm_pop_hword(vm).as_hword;
|
||||||
|
vm_push_hword(vm, DHWORD(!a));
|
||||||
|
}
|
||||||
|
|
||||||
|
void vm_not_word(vm_t *vm)
|
||||||
|
{
|
||||||
|
if (vm->stack.ptr < WORD_SIZE)
|
||||||
|
// TODO: Error STACK_UNDERFLOW
|
||||||
|
return;
|
||||||
|
|
||||||
|
word a = vm_pop_word(vm).as_word;
|
||||||
|
vm_push_word(vm, DWORD(!a));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,4 +100,15 @@ static const pop_f POP_ROUTINES[] = {
|
|||||||
[OP_POP_WORD] = vm_pop_word,
|
[OP_POP_WORD] = vm_pop_word,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void vm_not_byte(vm_t *);
|
||||||
|
void vm_not_hword(vm_t *);
|
||||||
|
void vm_not_word(vm_t *);
|
||||||
|
|
||||||
|
typedef void (*not_f)(vm_t *);
|
||||||
|
static const not_f NOT_ROUTINES[] = {
|
||||||
|
[OP_NOT_BYTE] = vm_not_byte,
|
||||||
|
[OP_NOT_HWORD] = vm_not_hword,
|
||||||
|
[OP_NOT_WORD] = vm_not_word,
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user