From eb174175baadc3bc1031ad299b193bade01d6884 Mon Sep 17 00:00:00 2001
From: Jose Antonio Ortega Ruiz <jao@gnu.org>
Date: Sun, 24 Mar 2002 00:23:28 +0000
Subject: wrapping up location pointer when address 3999 is reached

---
 mixlib/xmix_vm.h | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

(limited to 'mixlib')

diff --git a/mixlib/xmix_vm.h b/mixlib/xmix_vm.h
index 60185df..019dfd6 100644
--- a/mixlib/xmix_vm.h
+++ b/mixlib/xmix_vm.h
@@ -2,9 +2,9 @@
  * This file contains internal declarations used in the implementation
  * of the mix_vm_t type.
  * ------------------------------------------------------------------
- *  $Id: xmix_vm.h,v 1.6 2001/09/16 22:38:43 jao Exp $
+ *  $Id: xmix_vm.h,v 1.7 2002/03/24 00:23:28 jao Exp $
  * ------------------------------------------------------------------
- * Copyright (C) 2000 Free Software Foundation, Inc.
+ * Copyright (C) 2000, 2002 Free Software Foundation, Inc.
  *  
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -35,7 +35,13 @@
 #include "mix_vm.h"
 
 /* The mix_vm_t type */
-enum {IREG_NO_ = 6, BD_NO_ = 21, MEM_CELLS_NO_ = MIX_VM_CELL_NO};
+enum {
+  IREG_NO_ = 6,
+  BD_NO_ = 21,
+  MEM_CELLS_NO_ = MIX_VM_CELL_NO,
+  MEM_CELLS_MAX_ = MIX_VM_CELL_NO - 1
+};
+
 struct mix_vm_t 
 {
   mix_word_t reg[IREG_NO_+3];
@@ -98,14 +104,14 @@ do {						\
 
 #define set_cmp_(vm,x) (vm)->cmpflag = (x)
 #define set_over_(vm,x) (vm)->overflow = (x)
-#define set_loc_(vm,x)  (vm)->loc_count = (x)&MIX_SHORT_MAX
+#define set_loc_(vm,x)  (vm)->loc_count = (MEMOK_(x)? (x) : MIX_SHORT_ZERO)
 
 #define set_status_(vm,s) ((vm)->status = (s))
 
-#define inc_loc_(vm)   				\
+#define inc_loc_(vm)				\
 do {						\
-  vm->loc_count++;				\
-  vm->loc_count &= MIX_SHORT_MAX;		\
+  if (vm->loc_count++ == MEM_CELLS_MAX_)	\
+    vm->loc_count = MIX_SHORT_ZERO;		\
 } while(FALSE)
 
 #define is_halted_(vm) ((vm)->status == MIX_VM_HALT)
-- 
cgit v1.2.3