Implemented vm routines for OP_XOR_*

This commit is contained in:
2023-10-21 23:55:41 +01:00
parent c9b23b7b24
commit 50ce1b35cd
2 changed files with 40 additions and 0 deletions

View File

@@ -426,3 +426,33 @@ void vm_and_word(vm_t *vm)
vm_push_word(vm, DWORD(a & b));
}
void vm_xor_byte(vm_t *vm)
{
if (vm->stack.ptr < 2)
// TODO: Error STACK_UNDERFLOW
return;
byte a = vm_pop_byte(vm).as_byte;
byte b = vm_pop_byte(vm).as_byte;
vm_push_byte(vm, DBYTE(a ^ b));
}
void vm_xor_hword(vm_t *vm)
{
if (vm->stack.ptr < (HWORD_SIZE * 2))
// TODO: Error STACK_UNDERFLOW
return;
hword a = vm_pop_hword(vm).as_hword;
hword b = vm_pop_hword(vm).as_hword;
vm_push_hword(vm, DHWORD(a ^ b));
}
void vm_xor_word(vm_t *vm)
{
if (vm->stack.ptr < (WORD_SIZE * 2))
// TODO: Error STACK_UNDERFLOW
return;
word a = vm_pop_word(vm).as_word;
word b = vm_pop_word(vm).as_word;
vm_push_word(vm, DWORD(a ^ b));
}

View File

@@ -131,4 +131,14 @@ static const and_f AND_ROUTINES[] = {
[OP_AND_WORD] = vm_and_word,
};
void vm_xor_byte(vm_t *);
void vm_xor_hword(vm_t *);
void vm_xor_word(vm_t *);
typedef void (*xor_f)(vm_t *);
static const xor_f XOR_ROUTINES[] = {
[OP_XOR_BYTE] = vm_xor_byte,
[OP_XOR_HWORD] = vm_xor_hword,
[OP_XOR_WORD] = vm_xor_word,
};
#endif