msp4th: include msp4th_puts(uint8_t *s) in ROM
authorDan White <dan@whiteaudio.com>
Wed, 8 May 2013 19:02:53 +0000 (14:02 -0500)
committerDan White <dan@whiteaudio.com>
Wed, 8 May 2013 19:02:53 +0000 (14:02 -0500)
Now, it merely requires putchar/getchar from the user.

msp4th/main.c
msp4th/msp4th.c
msp4th/msp4th.h
msp4th/test4th.c

index aea5470add4bd73cb4589444a216c3075762b231..b150423dbe3f60c09969a97bafea63b5347a7f4b 100644 (file)
@@ -112,7 +112,7 @@ uint8_t __attribute__ ((section(".noinit"))) cmdListArray[USER_CMD_LIST_SIZE];
 
 void (*msp4th_putchar)(uint8_t);
 uint8_t (*msp4th_getchar)(void);
-void (*msp4th_puts)(uint8_t *);
+
 
 void config_default_msp4th(void)
 {
@@ -135,7 +135,6 @@ void config_default_msp4th(void)
 
     msp4th_putchar = &uart_putchar;
     msp4th_getchar = &uart_getchar;
-    msp4th_puts = &uart_puts;
 }
 
 
index cd0e702b3e367d76cd09a9c90895fd307f7a6a38..0d542e6fdcdd2fed392e506b3c31124dc4904eac 100644 (file)
@@ -2,9 +2,15 @@
  *
  * TODO:
  *  - use enum for VM opcodes
- *  - speed up pop/pushMathStack (need bounds check??)
- *  - UART usage is blocking, convert to interrupt-based
- *  - allow configurable user-code space
+ *
+ *  X speed up pop/pushMathStack (need bounds check??)
+ *      only bounds check is for mathStack underflow
+ *
+ *  X UART usage is blocking, convert to interrupt-based
+ *      user may provide msp4th_{putchar,getchar} function pointers
+ *      the default one remains blocking
+ *
+ *  X allow configurable user-code space
  *      mathStack[], addrStack[]
  *      prog[], cmdList[], progOpcodes[]
  *      array locations come from a vector table instead of hard-coded
@@ -29,7 +35,6 @@ typedef uint8_t str_t;
 #include "msp4th.h"
 
 
-#define ALIGN_2 __attribute__ ((aligned (2)))
 
 /* 
  * Hard-coded constants
@@ -101,7 +106,7 @@ const int16_t cmdList2N[] = {0,10000,10032,10135};  // need an extra zero at the
 
 // to flag the initial built in functions from the rest, save the negative of them in the program space (prog).
 
-const int16_t ALIGN_2 progBi[] = { // address actually start at 10000
+const int16_t progBi[] = { // address actually start at 10000
 
    // this is the monitor in compiled forth code (by hand)
 
@@ -315,14 +320,13 @@ uint16_t lineBufferIdx;             /* input line buffer pointer */
 
 uint8_t wordBuffer[WORD_SIZE];      // just get a word
 
+
+
 /* The following utilize a vector table to allow re-configuring the
  * location/size of these arrays.  Then the stack sizes and user program space
  * sizes can be (re-)specified by changing the table and calling init_msp4th()
  * again.
  */
-
-
-
 #if defined(MSP430)
 int16_t register *mathStackPtr asm("r6");
 #else
@@ -345,8 +349,6 @@ uint8_t *cmdList;       // string of user defined word names
 uint16_t cmdListIdx;    // next open space for user word strings
 
 
-// TODO re-defined
-
 
 
 
@@ -364,6 +366,20 @@ static int16_t RAMerrors(void){
 }
 
 
+void msp4th_puts(uint8_t *s)
+{
+    uint16_t i = 0;
+    uint8_t c = 1;
+
+    while (c != 0) {
+        c = s[i++];
+        msp4th_putchar(c);
+    }
+    msp4th_putchar('\r');
+    msp4th_putchar('\n');
+}
+
+
 uint8_t getKeyB(){
     uint8_t c;
 
index 2f4f16360101bcf7ac28dbf555aec10e6ddb5fab..62a0dce8e2749568d81015ecaf33d415f63aeb51 100644 (file)
@@ -21,7 +21,6 @@ extern volatile uint8_t *cmdListStartAddress;
  */
 extern void (*msp4th_putchar)(uint8_t c);
 extern uint8_t (*msp4th_getchar)(void);
-extern void (*msp4th_puts)(uint8_t *s);
 
 void init_msp4th(void);
 void processLoop(void);
index 8520e50da010dec2f6d56bda107184b3b24984b8..bd2c77abfd16f800bd0837fe8b48cf610fb62069 100644 (file)
@@ -4,9 +4,6 @@
 
 #include "msp4th.h"
 
-void (*msp4th_putchar)(uint8_t);
-uint8_t (*msp4th_getchar)(void);
-void (*msp4th_puts)(uint8_t *);
 
 
 #define MATH_STACK_SIZE 32
@@ -27,6 +24,9 @@ volatile int16_t *progStartAddress;
 volatile int16_t *progOpcodesStartAddress;
 volatile uint8_t *cmdListStartAddress;
 
+void (*msp4th_putchar)(uint8_t);
+uint8_t (*msp4th_getchar)(void);
+
 
 
 void my_putchar(uint8_t c)
@@ -41,11 +41,6 @@ uint8_t my_getchar(void)
 }
 
 
-void my_puts(uint8_t *s)
-{
-    puts((char *)s);
-}
-
 
 
 void config_msp4th(void)
@@ -68,7 +63,6 @@ void config_msp4th(void)
 
     msp4th_putchar = &my_putchar;
     msp4th_getchar = &my_getchar;
-    msp4th_puts = &my_puts;
 }