diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2002-03-24 00:23:28 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2002-03-24 00:23:28 +0000 |
commit | eb174175baadc3bc1031ad299b193bade01d6884 (patch) | |
tree | be1d0c0be35b5307d0c034be49d871b4574812ea | |
parent | 7225f7abf5cf6a0f254717281546c10f389b0a21 (diff) | |
download | mdk-eb174175baadc3bc1031ad299b193bade01d6884.tar.gz mdk-eb174175baadc3bc1031ad299b193bade01d6884.tar.bz2 |
wrapping up location pointer when address 3999 is reached
-rw-r--r-- | mixlib/xmix_vm.h | 20 |
1 files changed, 13 insertions, 7 deletions
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) |