first commit
This commit is contained in:
32
src/instructions/impl/impl_macros.h
Normal file
32
src/instructions/impl/impl_macros.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include "../instructions.h"
|
||||
|
||||
#define readVar(VAR) {\
|
||||
if(!VM_dataRead(vm, &VAR, pos, sizeof(VAR))) \
|
||||
return -1;\
|
||||
pos += sizeof(VAR);\
|
||||
}
|
||||
|
||||
#define validateRegisterIndex(VAR) {\
|
||||
if(VAR > sizeof(vm->registers)){\
|
||||
VM_setErrorMessage(vm, "[%p] invalid register index (%x)", (void*)pos, VAR);\
|
||||
return -1;\
|
||||
}\
|
||||
}
|
||||
|
||||
#define readRegisterVar(VAR) {\
|
||||
readVar(VAR);\
|
||||
validateRegisterIndex(VAR);\
|
||||
}
|
||||
|
||||
#define validateValueSize(VAR) {\
|
||||
if(VAR < 1 || VAR > 4){\
|
||||
VM_setErrorMessage(vm, "[%p] invalid value_size (%x)", (void*)pos, VAR);\
|
||||
return -1;\
|
||||
}\
|
||||
}
|
||||
|
||||
#define readValueSizeVar(VAR) {\
|
||||
readVar(VAR);\
|
||||
validateValueSize(VAR);\
|
||||
}
|
||||
Reference in New Issue
Block a user