~crc_/retroforth

68f2fa9b09b35586a5f38ef548a3d151fa0fd172 — crc 6 months ago 55652d8
nga-c: add stub guard() function (ref #96)

FossilOrigin-Name: 872b8371d1eed28ce2b6405055f5ada8b174c2c55b5dbbbfd35e857dff4665a6
1 files changed, 19 insertions(+), 0 deletions(-)

M vm/nga-c/retro.c
M vm/nga-c/retro.c => vm/nga-c/retro.c +19 -0
@@ 237,6 237,25 @@ void inst_iq(NgaState *);  void inst_ii(NgaState *);

/* 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 --------------------------------- */
#ifdef ENABLE_MALLOC
#ifdef BIT64