From 305f387241858561b54441500fba67cb2375233f Mon Sep 17 00:00:00 2001 From: Dan White Date: Wed, 8 May 2013 14:02:53 -0500 Subject: [PATCH] msp4th: include msp4th_puts(uint8_t *s) in ROM Now, it merely requires putchar/getchar from the user. --- msp4th/main.c | 3 +-- msp4th/msp4th.c | 36 ++++++++++++++++++++++++++---------- msp4th/msp4th.h | 1 - msp4th/test4th.c | 12 +++--------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/msp4th/main.c b/msp4th/main.c index aea5470..b150423 100644 --- a/msp4th/main.c +++ b/msp4th/main.c @@ -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; } diff --git a/msp4th/msp4th.c b/msp4th/msp4th.c index cd0e702..0d542e6 100644 --- a/msp4th/msp4th.c +++ b/msp4th/msp4th.c @@ -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; diff --git a/msp4th/msp4th.h b/msp4th/msp4th.h index 2f4f163..62a0dce 100644 --- a/msp4th/msp4th.h +++ b/msp4th/msp4th.h @@ -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); diff --git a/msp4th/test4th.c b/msp4th/test4th.c index 8520e50..bd2c77a 100644 --- a/msp4th/test4th.c +++ b/msp4th/test4th.c @@ -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; } -- 2.25.1