msp4th: style cleanup
authorDan White <dan@whiteaudio.com>
Sun, 12 May 2013 02:24:23 +0000 (21:24 -0500)
committerDan White <dan@whiteaudio.com>
Sun, 12 May 2013 02:24:23 +0000 (21:24 -0500)
msp4th/bootrom.rcf
msp4th/msp4th.c

index 42b2026e1f2915764741da49e5ba01f32ca4c34c..162b5e2bbff7cd2ee158eca47a6ab31143ba1fd9 100644 (file)
 0001001010110000
 0011000110100000
 0001001010110000
-0011110001000000
+0011110001000110
 0011111111001111
 0100000000110000
-0011111111001010
+0011111111010000
 0100000000110001
 1111111100000000
 0100000000110000
 0100000100111011
 0100000100110000
 0100000000111111
-0011110010100010
+0011110010101000
 0001001010010010
 0100000000011000
 0100000000111111
-0011110111001010
+0011110111010000
 0001001010010010
 0100000000011000
 0100001000011111
 0100001000011010
 0100000000000110
 0100000000111110
-0011110010100010
+0011110010101000
 0100101000001111
 0001001010110000
 0011001111100010
 0100111000100000
 0011110000010010
 0100000000111110
-0011110111001010
+0011110111010000
 0100101000001111
 0001001010110000
 0011001111100010
 0100111000001101
 0101110100001101
 0101000000111101
-1110111110111100
+1110111111000010
 0011110000000100
 0100111000001101
 0101110100001101
 0100111000001111
 0101111100001111
 0101000000111111
-1110111110111100
+1110111111000010
 0011110000000100
 0100111000001111
 0101111100001111
 0100000000111010
 0000000000001010
 0001001010110000
-0011111100000100
+0011111100001010
 0101000001111110
 0000000000110000
 0100111011001000
 0100000000111010
 0000000000001010
 0001001010110000
-0011111100000100
+0011111100001010
 0100110000001111
 0101001100011001
 1001001100001100
 0000000001001100
 0010100000000010
 0100000000110000
-0011101111110010
+0011101111111000
 0101111100001111
 0100111100010000
 0011011101101110
 0011100100100010
 0011100100111000
 0011100101000000
-0011101111110010
-0011101111110010
+0011101111111000
+0011101111111000
 0011100101000100
 0011100101001010
 0011100101100110
 0011100110010010
-0011101111110010
+0011101111111000
 0011100110100110
 0011100110101110
 0011100110110010
-0011100110111010
-0011100111000000
-0011100111000110
-0011100111001100
-0011100111010010
-0011100111010110
-0011100111100000
-0011100111101100
-0011100111110110
-0011101000000010
-0011101000010100
-0011101000011010
-0011101000111010
-0011101000111110
-0011101001001000
-0011101001001110
-0011101001010100
-0011101001011010
-0011101001100000
-0011101001100110
-0011101001101100
-0011101001110010
-0011101010110000
-0011101010111000
-0011101011000110
-0011101011001100
-0011101011010000
-0011101011011010
-0011101011101010
-0011101100000000
-0011101100011100
-0011101100111010
-0011101101000000
-0011101101000100
-0011101101011000
-0011101101100010
-0011101101101110
-0011101110000010
-0011101110010000
-0011101110100000
-0011101110110100
-0011101111010000
-0011101111011100
-0011101111100110
+0011100110111100
+0011100111000010
+0011100111001000
+0011100111001110
+0011100111010100
+0011100111011000
+0011100111100010
+0011100111101110
+0011100111111000
+0011101000000100
+0011101000010110
+0011101000011100
+0011101000111100
+0011101001000000
+0011101001001010
+0011101001010000
+0011101001010110
+0011101001011100
+0011101001100010
+0011101001101000
+0011101001101110
+0011101001110100
+0011101010110010
+0011101010111010
+0011101011001000
+0011101011001110
+0011101011010010
+0011101011011100
+0011101011101100
+0011101100000010
+0011101100011110
+0011101100111100
+0011101101000010
+0011101101000110
+0011101101011010
+0011101101100100
+0011101101110000
+0011101110000100
+0011101110010010
+0011101110100010
+0011101110110110
+0011101111010010
+0011101111011110
+0011101111101000
 0100001110010010
 0100000000000100
 0100000000110000
-0011101111110010
+0011101111111000
 0101011010100110
 0000000000000010
 0011110000000010
 0001001010110000
 0011001110110110
 0100000000110000
-0011101111110010
+0011101111111000
 1100001000110010
 0100011000001110
 0101001100101110
 0000000000000000
 1101001000110010
 0100000000110000
-0011101111110010
+0011101111111000
 0100011000011100
 0000000000000010
 0100011000101010
 0001001010110000
-0011111100100000
+0011111100100110
 0100110010000110
 0000000000000010
 0100111010000110
 0000000000000000
 0100000000110000
-0011101111110010
+0011101111111000
 0001001010110000
 0011001110110110
 0001001010110000
 0011011010001110
 0100000000110000
-0011101111110010
+0011101111111000
 0100011000101111
 0011110010010010
 0100011000101101
 0100110110001110
 0000000000000000
 0100000000110000
-0011101111110010
+0011101111111000
 0001001010110000
 0011001110110110
 0100011000001110
 0100001110011110
 0000000000000000
 0100000000110000
-0011101111110010
+0011101111111000
 0100001110001110
 0000000000000000
 0100000000110000
-0011101111110010
+0011101111111000
 0001001010110000
 0011001110110110
 0001001010110000
 0001001010110000
 0011001101001100
 0100000000110000
-0011101111110010
+0011101111111000
 0001001010110000
 0011011000110110
 0100000000110000
-0011101111110010
+0011101111111000
 0100011000101110
 1001001100001110
 0011100000000010
 0100000000110000
-0011101111110010
+0011101111111000
 1110001100111110
 0100111010000110
 0000000000000000
 0101001110010110
 0000000000000000
 0100000000110000
-0011101111110010
+0011101111111000
 0100001000011010
 0100000000100010
 0100101000001011
 0100101010000010
 0100000000100010
 0100000000110000
-0011101111110010
+0011101111111000
 0100011000101111
 0101111100001111
 0101001000011111
 0100111110100110
 0000000000000000
 0100000000110000
-0011101111110010
+0011101111111000
 0001001010110000
 0011001110110110
 0100111100001011
 0101001000011110
 0100000000001000
 0100000000110000
-0011101110011010
+0011101110011100
 1001001110000110
 0000000000000000
 0010010000000100
 0100001110000110
 0000000000000000
 0100000000110000
-0011101111110010
+0011101111111000
 0100001110010110
 0000000000000000
 0100000000110000
-0011101111110010
+0011101111111000
 0001001010110000
 0011001110011100
 0100000000110000
-0011101111110010
+0011101111111000
 0100001100001111
 0011110000111000
 0100001000011111
 0100000000011100
-0011110001110101
+0011110001110110
 0001001010110000
 0011001111001010
 0100111100001011
 1001001100001111
 0010010000000010
 0100000000110000
-0011101111110010
+0011101111111000
 1000001100100111
 0100101110000010
 0100000000011100
 0100000000110000
-0011101111110010
+0011101111111000
 0100001000011110
 0100000000010110
 0100111000001111
 0001001010110000
 0011001111000010
 0100000000110000
-0011101111110010
+0011101111111000
 0001001010110000
 0011001110110110
 0001001010110000
 0001001010010010
 0100000000000010
 0100000000110000
-0011101111110010
+0011101111111000
 0001001010110000
 0011010011010100
 0100000000110000
-0011101111110010
+0011101111111000
 0100001100001111
 0011111111101100
 0100001100011111
 0001001010110000
 0011010110000110
-0011110100011100
+0100000000110000
+0011101111111000
 0001001010110000
-0011101111111100
-0011110100011001
+0011110000000010
+0011110100011011
 0001001010110000
 0011010001111110
-0011110100010110
+0011110100011000
 0001001010110000
 0011011000000010
-0011110100010011
+0011110100010101
 0001001010110000
 0011011000101100
-0011110100010000
+0011110100010010
 0100001100011111
-0011111111011010
+0011111111011001
 0100001000011111
 0100000000000110
 0001001010010010
 0100000000011000
-0011110100001001
+0011110100001011
 0100001000011011
 0100000000000010
 0001001010110000
 0011001110110110
 0001001010001011
-0011110100000011
+0011110100000101
 0001001010110000
 0011001111001010
 0100111110000010
 0100000000011100
-0011110011111110
+0011110100000000
 0100011000101110
 1111000000111110
 1111111111111110
 0100111010100110
 0000000000000000
-0011110011111000
+0011110011111010
 0001001010110000
 0011001110110110
 0100111100001011
 0011110011000011
 0100001000011111
 0100000000100010
-0011111110111000
+0011111110110111
 0001001010110000
 0011001110110110
 0100111100001010
 0100101100001111
 0001001010110000
 0011001111010000
-0011110011011100
+0011110011011110
 0100001100011111
 0011110000000010
 0001001010110000
 0011001110110110
 0001001010110000
 0011010111000000
-0011110011010101
+0011110011010111
 0100011100011111
 0000000000000010
-0011111110011110
+0011111110011101
 0100011100011111
 0000000000001000
-0011111110011011
+0011111110011010
 0100011100011111
 0000000000001110
-0011111110011000
+0011111110010111
 1110001110110110
 0000000000000000
-0011110011001001
+0011110011001011
 1110011010100110
 0000000000000010
-0011111011011001
+0011111011011000
 1111011010100110
 0000000000000010
-0011111011010110
+0011111011010101
 1101011010100110
 0000000000000010
-0011111011010011
+0011111011010010
 1100001000110010
 0001001010110000
 0011001110110110
 0001000010001011
 0001000110001011
 0001001010110000
-0011111101010110
+0011111101011100
 0100110000001011
 0001001010110000
 0011001110110110
 0100101110000110
 0000000000000000
-0011110010100001
+0011110010100011
 0001001010010010
 0100000000010000
 0100111101001111
-0011111101101001
+0011111101101000
 0100000001111111
 0000000000001101
 0001001010010010
 0100000000000010
 0100000001111111
 0000000000001010
-0011111101101100
+0011111101101011
 0101011010100110
 0000000000000000
-0011110010010011
+0011110010010101
 0001000100100110
-0011110010010001
+0011110010010011
 0100011000001011
 0001001010100110
 0100111110001011
 0000000000000000
-0011110010001100
+0011110010001110
 0100011000001011
 0101001100101011
 0100101100101111
 0000000000000000
 0001001010110000
 0011001111011000
-0011110001011001
+0011110001011011
 0001000010000110
-0011110001010111
+0011110001011001
 0001001010110000
 0011001110110110
 0100111100001011
 0101111000001110
 0101111110001110
 0000000000000000
-0011110001001101
+0011110001001111
 0001001010110000
 0011001110110110
 0001001010110000
 0011010111101000
-0011110001001000
+0011110001001010
 0001001010110000
 0011001110110110
 0101111100001111
 0101011000001111
 0100111100101111
-0011111100001110
+0011111100001101
 0100011000011011
 0000000000000010
 0100011000101111
 0000000000000100
 0100101110000110
 0000000000000010
-0011110000111000
+0011110000111010
 0001001010110000
 0011001110110110
 0100011000001110
 1001111110000110
 0000000000000000
-0011010000110010
+0011010000110100
 0011110000000101
 0001001010110000
 0011001110110110
 0100011000001110
 1001011000101111
-0011010000101100
+0011010000101110
 0100111110001110
 0000000000000000
-0011110000101001
+0011110000101011
 0100001000011011
 0100000000010110
 0011110000000100
 1000001100101011
 1001011000001011
 0010111111111010
-0011110000011111
+0011110000100001
 0100001000011011
 0100000000010110
 0011110000001000
 1000001100101011
 1001011000001011
 0010111111110110
-0011110000010001
+0011110000010011
 0100011000101110
 1110001100111110
 0101001100011110
 0100111010000110
 0000000000000000
-0011110000001011
+0011110000001101
 0001001010110000
 0011001110110110
 0100111110000010
 0100000000001100
-0011110000000110
-0100001110000010
+0011110000001000
+0100001000011111
 0100000000000000
+0100001111001111
+0000000000000000
 0001001010110000
 0011001110110110
 0001001010110000
 0011001111010000
 0101101100001011
 0101000000111011
-1110111110110100
+1110111110111010
 0011110000000111
 0100001000011111
 0100000000011100
 0100111000001111
 0101111100001111
 0101000000111111
-1110111110111100
+1110111111000010
 0011110000000100
 0100111000001111
 0101111100001111
 0101001100011010
 1101001000111101
 0001001010110000
-0011111100000100
+0011111100001010
 0001000000001101
 1011001000101101
 0010100000000100
 0110001100001011
 1101001000111000
 0001001010110000
-0011111110100000
+0011111110100110
 0001000000001000
 1011001000101000
 0010010000001000
 0000000000000000
 0000000000000000
 0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
index 4da029180591a3ec6b752e5d743c1e2bb3943142..b9a89dc1ab13853a63fdfb28db2f9a78023b70db 100644 (file)
@@ -424,7 +424,7 @@ void msp4th_init(struct msp4th_config *c)
 }
 
 
-void msp4th_processLoop() // this processes the forth opcodes.
+void msp4th_processLoop(void) // this processes the forth opcodes.
 {
     uint16_t opcode;
     uint16_t tmp;
@@ -451,14 +451,13 @@ void msp4th_processLoop() // this processes the forth opcodes.
 
 
 
+/****************************************************************************
+ *
+ * The rest of the implementation
+ *
+ ***************************************************************************/
 
-
-
-
-
-
-
-uint8_t getKeyB()
+uint8_t getKeyB(void)
 {
     uint8_t c;
 
@@ -472,7 +471,7 @@ uint8_t getKeyB()
 }
 
 
-void getLine()
+void getLine(void)
 {
     int16_t waiting;
     uint8_t c;
@@ -584,7 +583,7 @@ void getWord(void)
 }
 
 
-void listFunction()
+void listFunction(void)
 {
     msp4th_puts((uint8_t *)cmdListBi);
     msp4th_puts((uint8_t *)cmdListBi2);
@@ -678,85 +677,92 @@ void ndropFunc(void)
 
 int16_t lookupToken(uint8_t *x, uint8_t *l) // looking for x in l
 {
-  int16_t i,j,k,n;
-
-  i = 0;
-  j = 0;
-  k = 0;
-  n = 1;
-
-  while(l[i] != 0){
-    if(x[j] != 0){   
-      // we expect the next char to match
-      if(l[i] == ' '){
-        // can't match x is longer than the one we were looking at
-        j = 0;
-        n++;
-        while(l[i] > ' '){ i++; }
-      } else {
-        if(l[i] == x[j]){
-          j++;
+    int16_t i,j,k,n;
+
+    i = 0;
+    j = 0;
+    k = 0;
+    n = 1;
+
+    while (l[i] != 0) {
+        if (x[j] != 0) {
+            // we expect the next char to match
+            if (l[i] == ' ') {
+                // can't match x is longer than the one we were looking at
+                j = 0;
+                n++;
+                while (l[i] > ' ') {
+                    i++;
+                }
+            } else {
+                if (l[i] == x[j]) {
+                    j++;
+                } else {
+                    j = 0;
+                    while (l[i] > ' ') {
+                        i++;
+                    }
+                    n++;
+                }
+            }
         } else {
-          j = 0;
-          while(l[i] > ' '){ i++; }
-          n++;
-        }
-      }
-    } else {
-      // ran out of input ... did we hit the space we expected???
-      if(l[i] == ' '){
-        // we found it.
-        k = n;
-        while(l[i] != 0){
-          i++;
+            // ran out of input ... did we hit the space we expected???
+            if (l[i] == ' ') {
+                // we found it.
+                k = n;
+                while (l[i] != 0) {
+                    i++;
+                }
+            } else {
+                // missed it
+                j = 0;
+                n++;
+                while (l[i] > ' ') {
+                    i++;
+                }
+            }
         }
-      } else {
-        // missed it
-        j = 0;
-        n++;
-        while(l[i] > ' '){ i++; }
-
-      }
+        i++;
     }
-    i++;
-  }
 
-  return(k);
+    return(k);
 }
 
 
-void luFunc()
+void luFunc(void)
 {
-  int16_t i;
-  
-  i = lookupToken(wordBuffer, (uint8_t *)cmdListBi);
-  
-  if(i){
-    i += 20000;
-    pushMathStack(i);
-    pushMathStack(1);
-  } else {
-    // need to test internal interp commands
-    i = lookupToken(wordBuffer, (uint8_t *)cmdListBi2);
-    if(i){
-      i += 10000;
-      pushMathStack(i);
-      pushMathStack(1);
-    } else {
-      i = lookupToken(wordBuffer, cmdList);
-      if(i){
+    int16_t i;
+
+    i = lookupToken(wordBuffer, (uint8_t *)cmdListBi);
+
+    if (i) {
+        i += 20000;
         pushMathStack(i);
         pushMathStack(1);
-      } else {
-        pushMathStack(0);
-      }
+    } else {
+        // need to test internal interp commands
+        i = lookupToken(wordBuffer, (uint8_t *)cmdListBi2);
+        if (i) {
+            i += 10000;
+            pushMathStack(i);
+            pushMathStack(1);
+        } else {
+            i = lookupToken(wordBuffer, cmdList);
+            if (i) {
+                pushMathStack(i);
+                pushMathStack(1);
+            } else {
+                pushMathStack(0);
+            }
+        }
     }
-  }  
-} 
+}
 
 
-void numFunc()
-{  // the word to test is in wordBuffer
+void numFunc(void)
+{
+    // the word to test is in wordBuffer
+
     uint16_t i;
     int16_t isnum;
     int16_t n;
@@ -774,14 +780,14 @@ void numFunc()
         // it is a number 
         isnum = 1;
         // check if hex
-        if(wordBuffer[0] == '0' && wordBuffer[1] == 'x'){
+        if (wordBuffer[0] == '0' && wordBuffer[1] == 'x') {
             // base 16 number ... just assume all characters are good
             i = 2;
             n = 0;
-            while(wordBuffer[i]){
+            while (wordBuffer[i]) {
                 n = n << 4;
                 n = n + wordBuffer[i] - '0';
-                if(wordBuffer[i] > '9'){
+                if (wordBuffer[i] > '9') {
                     n = n - 7;
 
                     // compensate for lowercase digits
@@ -794,12 +800,12 @@ void numFunc()
         } else {
             // base 10 number
             n = 0;
-            while(wordBuffer[i]){
+            while (wordBuffer[i]) {
                 n = n * 10;
                 n = n + wordBuffer[i] - '0';
                 i = i + 1;
             }
-            if(wordBuffer[0] == '-'){
+            if (wordBuffer[0] == '-') {
                 n = -n;
             }
         }
@@ -810,7 +816,9 @@ void numFunc()
 }
 
 
-void ifFunc(int16_t x){     // used as goto if x == 1
+void ifFunc(int16_t x){
+    // used as goto if x == 1
+
     uint16_t addr;
     uint16_t tmp;
     int16_t i;
@@ -824,7 +832,7 @@ void ifFunc(int16_t x){     // used as goto if x == 1
 
     progCounter++;
 
-    if(x == 1){
+    if (x == 1) {
         // this is a goto
         progCounter = addr;
     } else {
@@ -878,37 +886,44 @@ void rollFunc(int16_t n)
 }
 
 
-void pushnFunc(){
-  int16_t i;
-  if(progCounter > 9999){
-    i = progBi[progCounter - 10000];
-  } else {
-    i = prog[progCounter];
-  }
-  progCounter = progCounter + 1;
-  pushMathStack(i);
+void pushnFunc(void)
+{
+    int16_t i;
+
+    if (progCounter > 9999) {
+        i = progBi[progCounter - 10000];
+    } else {
+        i = prog[progCounter];
+    }
+
+    progCounter = progCounter + 1;
+    pushMathStack(i);
 }
 
 
-void overFunc(){
-  int16_t i;
-  i = NOS;
-  pushMathStack(i);
+void overFunc(void)
+{
+    pushMathStack(NOS);
 }
 
 
-void dfnFunc(){
-  uint16_t i;
-  // this function adds a new def to the list and creats a new opcode
-  i = 0;
-  while(wordBuffer[i]){
-    cmdList[cmdListIdx++] = wordBuffer[i];
-    i = i + 1;
-  }
-  cmdList[cmdListIdx++] = ' ';
-  cmdList[cmdListIdx] = 0;
-  i = lookupToken(wordBuffer, cmdList);
-  progOpcodes[i] = progIdx;
+void dfnFunc(void)
+{
+    // this function adds a new def to the list and creates a new opcode
+
+    uint16_t i;
+
+    i = 0;
+
+    while (wordBuffer[i]) {
+        cmdList[cmdListIdx++] = wordBuffer[i];
+        i = i + 1;
+    }
+
+    cmdList[cmdListIdx++] = ' ';
+    cmdList[cmdListIdx] = 0;
+    i = lookupToken(wordBuffer, cmdList);
+    progOpcodes[i] = progIdx;
 }
 
 
@@ -943,53 +958,55 @@ void printNumber(register int16_t n)
 }
 
 
-void printHexChar(int16_t n){
-  n &= 0x0F;
-  if(n > 9){
-    n += 7;
-  }
-  n += '0';
-  msp4th_putchar(n);
-}
+void printHexChar(int16_t n)
+{
+    n &= 0x0F;
 
+    if (n > 9) {
+        n += 7;
+    }
 
-void printHexByte(int16_t n){
-  n &= 0xFF;
-  printHexChar(n >> 4);
-  printHexChar(n);
+    n += '0';
+    msp4th_putchar(n);
 }
 
 
-void printHexWord(int16_t n){
-  printHexByte(n >> 8);
-  printHexByte(n);
+void printHexByte(int16_t n)
+{
+    n &= 0xFF;
+    printHexChar(n >> 4);
+    printHexChar(n);
 }
 
 
-void execFunc(){
-  int16_t opcode;
-  opcode = popMathStack();
-
-  if(opcode > 19999){
-    // this is a built in opcode
-    execN(opcode - 20000);
-
-  } else if(opcode > 9999){
-
-    pushAddrStack(progCounter);
-    progCounter = cmdList2N[opcode-10000];
+void printHexWord(int16_t n)
+{
+    printHexByte(n >> 8);
+    printHexByte(n);
+}
 
-  } else {
 
-    pushAddrStack(progCounter);
-    progCounter = progOpcodes[opcode];
+void execFunc(void) {
+    int16_t opcode;
 
-  }
+    opcode = popMathStack();
 
+    if (opcode > 19999) {
+        // this is a built in opcode
+        execN(opcode - 20000);
+    } else if (opcode > 9999) {
+        // built in interp
+        pushAddrStack(progCounter);
+        progCounter = cmdList2N[opcode-10000];
+    } else {
+        pushAddrStack(progCounter);
+        progCounter = progOpcodes[opcode];
+    }
 }
 
 
-void execN(int16_t opcode){
+void execN(int16_t opcode)
+{
   int16_t i,j,k,m,n;
   int32_t x;
 
@@ -1448,16 +1465,7 @@ void execN(int16_t opcode){
       break;
 
     case 76: // init  ( &config -- ) \ clears buffers and calls msp4th_init
-#if defined(MSP430)
-      //saves 2 words of ROM
-      asm("mov.w #0, %[b](r3)\n"
-          : /* outputs */
-          : [b] "m" (lineBuffer) /* inputs */
-          : /* clobbers */
-         );
-#else
-      *lineBuffer = 0;
-#endif
+      *lineBuffer = 0; // if location is same, the call is recursive otherwise
       msp4th_init((struct msp4th_config *)popMathStack());
       break;