void (*msp4th_putchar)(uint8_t);
uint8_t (*msp4th_getchar)(void);
-void (*msp4th_puts)(uint8_t *);
+
void config_default_msp4th(void)
{
msp4th_putchar = &uart_putchar;
msp4th_getchar = &uart_getchar;
- msp4th_puts = &uart_puts;
}
*
* 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
#include "msp4th.h"
-#define ALIGN_2 __attribute__ ((aligned (2)))
/*
* Hard-coded constants
// 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)
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
uint16_t cmdListIdx; // next open space for user word strings
-// TODO re-defined
-
}
+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;
#include "msp4th.h"
-void (*msp4th_putchar)(uint8_t);
-uint8_t (*msp4th_getchar)(void);
-void (*msp4th_puts)(uint8_t *);
#define MATH_STACK_SIZE 32
volatile int16_t *progOpcodesStartAddress;
volatile uint8_t *cmdListStartAddress;
+void (*msp4th_putchar)(uint8_t);
+uint8_t (*msp4th_getchar)(void);
+
void my_putchar(uint8_t c)
}
-void my_puts(uint8_t *s)
-{
- puts((char *)s);
-}
-
void config_msp4th(void)
msp4th_putchar = &my_putchar;
msp4th_getchar = &my_getchar;
- msp4th_puts = &my_puts;
}