fix dirMemory access, the array index must be unsigned
authorDan White <dan@whiteaudio.com>
Sun, 1 Feb 2015 20:07:54 +0000 (14:07 -0600)
committerDan White <dan@whiteaudio.com>
Sun, 1 Feb 2015 20:07:54 +0000 (14:07 -0600)
msp4th/Makefile
msp4th/msp4th.c
msp4th/tests.4th

index 2ec2a1398ab57a98656efa5636d43c379c4b21c1..40c63a1a72f33077fc6644ddf16b158e724dc0af 100644 (file)
@@ -70,7 +70,7 @@ OBJECTS = $(SOURCES:.c=.o)
 ASSEMBLYS = $(SOURCES:.c=.lst)
 
 #all: $(TARGET).elf $(TARGET).hex $(TARGET).txt 
-all: $(TARGET).elf $(TARGET).hex $(TARGET).xout $(ASSEMBLYS)
+all: $(TARGET).elf $(TARGET).hex $(TARGET).xout $(ASSEMBLYS) _pc4th
 
 #we .include this, so it doesn't make it to the auto-generated dependencies
 main.o: flashboot.s
index 4bb3f315b2a2b38af1772e6926d64d7df8f01fa5..22d4e6fdf57fd6fa91a8740044eed8d7ae4430f3 100644 (file)
@@ -1247,14 +1247,14 @@ void execVM(int16_t opcode)
 
         case 41: // @  ( addr -- val ) \ read directly from memory address
             i = TOS >> 1;
-            TOS = dirMemory[i];
+            TOS = dirMemory[(uint16_t)i];
             break;
 
         case 42: // !  ( val addr -- ) \ write directly to memory address words only!
             i = popMathStack();  //  address to write to
             i = i >> 1;
             j = popMathStack();  //  value to write
-            dirMemory[i] = j;
+            dirMemory[(uint16_t)i] = j;
             break;
 
         case 43: // h@  ( -- prog ) \ get end of program code space
@@ -1408,7 +1408,7 @@ GCC_DIAG_ON(int-to-pointer-cast);
         case 66: // +!  ( n addr -- ) \ *addr += n
             i = popMathStack();
             j = popMathStack();
-            dirMemory[i] += j;
+            dirMemory[(uint16_t)i] += j;
             break;
 
         case 67: // roll  ( n -- ) \ nth stack removed and placed on top
index b1f84b9e56f5ac0ba1df6770aada1233eaa16470..f3e4ac2f9e314dfff790d017031e521cb8bb2e14 100644 (file)
@@ -206,10 +206,9 @@ test-pwrd bar
 
 \    case 41: // @  ( addr -- val ) \ read directly from memory address
 \    case 42: // !  ( val addr -- ) \ write directly to memory address words only!
-\ NOTE: Not working on PC version, fake dirMemory array needs debugging.
-\ 42 0xff00 !
-\ 0xff00 @
-\ 42 cmp
+42 0xff00 !
+0xff00 @
+42 cmp
 
 \    case 43: // h@  ( -- progIdx ) \ get end of program code space
 \ no test