nga-c: add stub guard() function (ref #96)
FossilOrigin-Name: 872b8371d1eed28ce2b6405055f5ada8b174c2c55b5dbbbfd35e857dff4665a6
This commit is contained in:
parent
55652d8a5d
commit
68f2fa9b09
1 changed files with 19 additions and 0 deletions
|
@ -237,6 +237,25 @@ void inst_iq(NgaState *); void inst_ii(NgaState *);
|
||||||
|
|
||||||
/* Global Variables -------------------------------------------------- */
|
/* Global Variables -------------------------------------------------- */
|
||||||
|
|
||||||
|
void guard(NgaState *vm, int n, int m, int diff) {
|
||||||
|
if (vm->cpu[vm->active].sp < n) {
|
||||||
|
vm->cpu[vm->active].sp = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (((vm->cpu[vm->active].sp + m) - n) > (STACK_DEPTH - 1)) {
|
||||||
|
vm->cpu[vm->active].sp = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (diff) {
|
||||||
|
if (vm->cpu[vm->active].rp + diff < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (vm->cpu[vm->active].rp + diff > (ADDRESSES - 1)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Dynamic Memory / `malloc` support --------------------------------- */
|
/* Dynamic Memory / `malloc` support --------------------------------- */
|
||||||
#ifdef ENABLE_MALLOC
|
#ifdef ENABLE_MALLOC
|
||||||
#ifdef BIT64
|
#ifdef BIT64
|
||||||
|
|
Loading…
Reference in a new issue