static __inline__ void setup_default_msp4th(void)
{
- default_config.mathStackStartAddress = &mathStackArray[MATH_STACK_SIZE - 1];
- default_config.addrStackStartAddress = &addrStackArray[ADDR_STACK_SIZE - 1];
+ default_config.mathStackStart = &mathStackArray[MATH_STACK_SIZE - 1];
+ default_config.addrStackStart = &addrStackArray[ADDR_STACK_SIZE - 1];
default_config.prog = &progArray[0];
default_config.progOpcodes = &progOpcodesArray[0];
default_config.cmdList = &cmdListArray[0];
int16_t *addrStackPtr;
#endif
-int16_t *mathStackStartAddress;
-int16_t *addrStackStartAddress;
+int16_t *mathStackStart;
+int16_t *addrStackStart;
int16_t *prog; // user programs (opcodes) are placed here
i = *mathStackPtr;
// prevent stack under-flow
- if (mathStackPtr < mathStackStartAddress) {
+ if (mathStackPtr < mathStackStart) {
mathStackPtr++;
}
break;
case 27: // depth ( -- n ) \ math stack depth
- pushMathStack(mathStackStartAddress - mathStackPtr);
+ pushMathStack(mathStackStart - mathStackPtr);
break;
case 28: // .h ( a -- )
case 72: // s. ( -- ) \ print stack contents, TOS on right
{ // addr is strictly local to this block
int16_t *addr;
- addr = mathStackStartAddress;
+ addr = mathStackStart;
while (addr >= mathStackPtr) {
printNumber(*addr);
addr--;
case 73: // sh. ( -- ) \ print stack contents in hex, TOS on right
{ // addr is strictly local to this block
int16_t *addr;
- addr = mathStackStartAddress;
+ addr = mathStackStart;
while (addr >= mathStackPtr) {
printHexWord(*addr);
msp4th_putchar(' ');
* Changing the values in the msp4th_* locations and calling
* init_msp4th() again restarts the interpreter with the new layout;
*/
- mathStackPtr = c->mathStackStartAddress;
- addrStackPtr = c->addrStackStartAddress;
- mathStackStartAddress = c->mathStackStartAddress;
- addrStackStartAddress = c->addrStackStartAddress;
+ mathStackPtr = c->mathStackStart;
+ addrStackPtr = c->addrStackStart;
+ mathStackStart = c->mathStackStart;
+ addrStackStart = c->addrStackStart;
prog = c->prog;
progOpcodes = c->progOpcodes;
cmdList = c->cmdList;
*/
struct msp4th_config {
- int16_t *mathStackStartAddress;
- int16_t *addrStackStartAddress;
+ int16_t *mathStackStart;
+ int16_t *addrStackStart;
int16_t *prog;
int16_t *progOpcodes;
uint8_t *cmdList;
uint8_t lineBufferArray[CMD_LIST_SIZE];
uint8_t wordBufferArray[CMD_LIST_SIZE];
-struct msp4th_config default_config;
+struct msp4th_config config;
-/*
-int16_t *msp4th_mathStackStartAddress;
-int16_t *msp4th_addrStackStartAddress;
-int16_t *msp4th_prog;
-int16_t *msp4th_progOpcodes;
-uint8_t *msp4th_cmdList;
-uint8_t *msp4th_lineBuffer;
-int16_t msp4th_lineBufferLength;
-uint8_t *msp4th_wordBuffer;
-int16_t msp4th_wordBufferLength;
-*/
-
-//void (*msp4th_putchar)(uint8_t);
-//uint8_t (*msp4th_getchar)(void);
{
int16_t i;
- default_config.mathStackStartAddress = &mathStackArray[MATH_STACK_SIZE - 1];
- default_config.addrStackStartAddress = &addrStackArray[ADDR_STACK_SIZE - 1];
- default_config.prog = &progArray[0];
- default_config.progOpcodes = &progOpcodesArray[0];
- default_config.cmdList = &cmdListArray[0];
- default_config.lineBuffer = &lineBufferArray[0];
- default_config.lineBufferLength = LINE_BUFFER_SIZE;
- default_config.wordBuffer = &wordBufferArray[0];
- default_config.wordBufferLength = WORD_BUFFER_SIZE;
- default_config.putchar = &my_putchar;
- default_config.getchar = &my_getchar;
+ config.mathStackStart = &mathStackArray[MATH_STACK_SIZE - 1];
+ config.addrStackStart = &addrStackArray[ADDR_STACK_SIZE - 1];
+ config.prog = &progArray[0];
+ config.progOpcodes = &progOpcodesArray[0];
+ config.cmdList = &cmdListArray[0];
+ config.lineBuffer = &lineBufferArray[0];
+ config.lineBufferLength = LINE_BUFFER_SIZE;
+ config.wordBuffer = &wordBufferArray[0];
+ config.wordBufferLength = WORD_BUFFER_SIZE;
+ config.putchar = &my_putchar;
+ config.getchar = &my_getchar;
// terminate the strings
lineBufferArray[0] = 0;
{
config_msp4th();
- msp4th_init(&default_config);
+ msp4th_init(&config);
msp4th_processLoop();
return 0;