From e94324a78fd8cd1e3d3b63588cdcd039c3cf8225 Mon Sep 17 00:00:00 2001 From: Dan White Date: Thu, 9 May 2013 15:17:33 -0500 Subject: [PATCH] msp4th: add 'echo' word, cleanup user-defined namespace Also allow testing of absolute address peek/poke on PC. --- msp4th/bootrom.rcf | 998 +++++++++++++++++----------------- msp4th/ldscript_ns430 | 14 +- msp4th/ldscript_ns430_bootrom | 14 +- msp4th/main.c | 33 +- msp4th/msp4th.c | 201 ++++--- msp4th/msp4th.h | 28 +- msp4th/test4th.c | 56 +- 7 files changed, 696 insertions(+), 648 deletions(-) diff --git a/msp4th/bootrom.rcf b/msp4th/bootrom.rcf index 881c6c2..7b031db 100644 --- a/msp4th/bootrom.rcf +++ b/msp4th/bootrom.rcf @@ -97,22 +97,6 @@ 0001101000000100 0100001000010000 1111111111111110 -1100001000110010 -0001001010110000 -0011000011100110 -0001001010110000 -0011000100001000 -0001001010110000 -0011101111100000 -0001001010110000 -0011110000111010 -0011111111111011 -0100000000110000 -0011111110111110 -0100000000110001 -1111111100000000 -0100000000110000 -0011000000000000 0100000010110010 0000000000110000 0001101000001100 @@ -129,45 +113,70 @@ 0010001000000000 0100001000011111 0010001000000100 -0100000100110000 0100000010110010 -0100000011110100 +0100000001010000 1111111100000000 0100000010110010 -0100000101110100 +0100000011010000 1111111100000010 0100000010110010 -0100000101110110 +0100000011010010 1111111100000100 0100000010110010 -0100001101110110 +0100001011010010 1111111100000110 0100000010110010 -0100001110110110 +0100001100010010 1111111100001000 +0100000010110010 +0100001110010010 +1111111100001010 +0100000010110010 +0000000010000000 +1111111100001100 +0100000010110010 +0100010000010010 +1111111100001110 +0100000010110010 +0000000000100000 +1111111100010000 0100000000111111 -0100000010110110 +0100000000010010 0100001110001111 0000000000000000 0101001100101111 1001000000111111 -0100000011110110 +0100000001010010 0010001111111010 0100000000111111 -0100000011110110 +0100000001010010 0100001110001111 0000000000000000 0101001100101111 1001000000111111 -0100000101110110 +0100000011010010 0010001111111010 +0100001111000010 +0100001110010010 +0100001111000010 +0100010000010010 0100000010110010 -0011000101010100 +0011000101100110 0100000000000000 0100000010110010 -0011000101100100 +0011000101110110 0100000000000010 -0100000100110000 +0001001010110000 +0011110001001010 +0001001010110000 +0011110001110110 +0011111111000110 +0100000000110000 +0011111111111110 +0100000000110001 +1111111100000000 +0100000000110000 +0011000000000000 1011000010110010 0000000000000011 0010001000000100 @@ -188,18 +197,18 @@ 0100101101101010 0100101001001111 0001001010110000 -0011000101010100 +0011000101100110 0101001100011011 1001001101001010 0010001111111001 0100000001111111 0000000000001101 0001001010110000 -0011000101010100 +0011000101100110 0100000001111111 0000000000001010 0001001010110000 -0011000101010100 +0011000101100110 0100000100111010 0100000100111011 0100000100110000 @@ -226,8 +235,12 @@ 0100000100110000 0001001000001011 0001001000001010 +0001001000001001 0100001110000010 -0100000010101000 +0100000000001000 +1001001110000010 +0100000000001010 +0010010000001100 0100000001111111 0000000000001101 0001001010010010 @@ -240,16 +253,20 @@ 0000000000111110 0001001010010010 0100000000000000 -0100000000111010 -0000000001111110 +0100001100011010 +0100001100001001 0001001010010010 0100000000000010 0100111101001011 +0100001000011110 +0100000000001010 +1001001100001110 +0010010000010001 1001001001111111 0010000000001111 -1001001110000010 -0100000010101000 -0010010000010110 +1001001000011001 +0100000000001000 +0011010000100010 0001001010010010 0100000000000000 0100000001111111 @@ -260,150 +277,173 @@ 0001001010010010 0100000000000000 0101001110110010 -0100000010101000 -0011111111101100 -1001001101111111 +0100000000001000 +0011110000111110 +1001001101111011 0010010000000010 -1001001001101111 -0010000000000110 +1001001001101011 +0010000000010000 1001001110000010 -0100000010101000 -0010000000000011 +0100000000001000 +0010000000001101 0100001110010010 -0100000010000100 -0011110000011001 +0100000000000100 +0100001000011111 +1111111100001010 +0100000011111111 +0000000001111000 +0000000000000000 +0100001000011111 +1111111100001010 +0100000011111111 +0000000000100000 +0000000000000001 +0011110000101100 +1001001100001110 +0010010000000011 0100101101001111 0001001010010010 0100000000000000 1001000001111011 0000000000001101 -0010010000000111 +0010010000001001 1001000001111011 0000000000001010 -0010010000000100 -0100001100011111 -1001001000011010 -0100000010101000 -0010110000000001 -0100001100001111 -0100001000011110 -0100000010101000 -0100101111001110 -0100000000000100 -0101001100011110 -0100111010000010 -0100000010101000 -0100001111001110 -0100000000000100 -1001001100001111 -0010001111001001 +0010010000000110 +0100001000011111 +1111111100001100 +0101001100111111 +1001111110000010 +0100000000001000 +0011100000001011 +1001001110000010 +0100000000001010 +0010010000000110 0100000001111111 0000000000001010 0001001010010010 0100000000000000 +0100001100001010 +0011110000000010 +0100001000011010 +0100000000001010 +0100001000011111 +0100000000001000 +0100001000011110 +1111111100001010 +0101111100001110 +0100101111001110 +0000000000000000 +0101001100011111 +0100111110000010 +0100000000001000 +0101001000011111 +1111111100001010 +0100001111001111 +0000000000000000 +1001001100001010 +0010001110101000 0100001110000010 -0100000010101000 +0100000000001000 +0100000100111001 0100000100111010 0100000100111011 0100000100110000 0100001000011110 -0100000010101000 -0100111001011111 -0100000000000100 +0100000000001000 +0100001000011111 +1111111100001010 +0101111000001111 +0100111101101111 0101001100011110 0100111010000010 -0100000010101000 +0100000000001000 1001001101001111 -0010000000001001 +0010000000001011 0001001010110000 -0011000111000100 +0011000111010110 0100001000011110 -0100000010101000 -0100111001011111 -0100000000000100 +0100000000001000 +0100001000011111 +1111111100001010 +0101111000001111 +0100111101101111 0101001100011110 0100111010000010 -0100000010101000 +0100000000001000 0100000100110000 0001001000001011 0001001010110000 -0011001001101000 +0011001010111110 0100000001111011 0000000000100000 0011110000000010 0001001010110000 -0011001001101000 +0011001010111110 1001111101001011 0010111111111100 0100000100111011 0100000100110000 0001001010110000 -0011001001101000 +0011001010111110 1001000001111111 0000000000101001 0010001111111011 0001001010110000 -0011001010001110 +0011001011101100 0100000100110000 0001001000001011 0001001000001010 -0100000000111111 -0100000010000110 -0100001111001111 -0000000000000000 -0101001100011111 -1001000000111111 -0100000010100110 -0010001111111010 0011110000000101 0001001010110000 -0011001010100110 +0011001100000100 0011110000000100 0001001010110000 -0011000111000100 +0011000111010110 0001001010110000 -0011001010001110 +0011001011101100 1001000001111111 0000000000101000 0010011111110110 1001000001111111 0000000001011100 0010011111110110 -0100111111000010 -0100000010000110 -0100001111000010 -0100000010000111 -0001001010110000 -0011001001101000 -0100000000111011 -0100000010000111 +0100001100001011 0100000001111010 0000000000100000 -0011110000000110 -0100111111001011 -1111111111111111 -0100001111001011 +0100001000011110 +1111111100001110 +0101101100001110 +0100111111001110 0000000000000000 -0001001010110000 -0011001001101000 0101001100011011 +0100001000011111 +1111111100001110 +0101101100001111 +0100001111001111 +0000000000000000 +0001001010110000 +0011001010111110 1001111101001010 -0010101111110111 +0010110000000011 +1001001000011011 +1111111100010000 +0011101111101110 0100000100111010 0100000100111011 0100000100110000 0100000000111111 -0011110010011100 +0011110011011000 0001001010110000 -0011000110011010 +0011000110101100 0100000000111111 -0011110110111110 +0011110111111111 0001001010110000 -0011000110011010 +0011000110101100 0100001000011111 -0100000010110000 +1111111100001000 0001001010110000 -0011000110011010 +0011000110101100 0100000100110000 0100011000101111 1001001000010110 @@ -512,76 +552,78 @@ 0100000100110000 0001001000001011 0001001000001010 +0001001000001001 +0100001000011010 +1111111100001110 0100000000111110 -0011110010011100 -0100000000111111 -0100000010000110 +0011110011011000 +0100101000001111 0001001010110000 -0011001101100100 -0100111100001010 +0011001110110100 +0100111100001001 1001001100001111 0010010000000011 0101000000111111 0100111000100000 -0011110000010100 +0011110000010010 0100000000111110 -0011110110111110 -0100000000111111 -0100000010000110 +0011110111111111 +0100101000001111 0001001010110000 -0011001101100100 +0011001110110100 0100111100001011 -1001101000001111 +1001100100001111 0010010000000011 0101000000111111 0010011100010000 -0011110000001000 +0011110000000111 0100001000011110 -0100000010110000 -0100000000111111 -0100000010000110 +1111111100001000 +0100101000001111 0001001010110000 -0011001101100100 +0011001110110100 1001101100001111 0010010000000011 0001001010110000 -0011001100111010 +0011001110001010 0100001100011111 0001001010110000 -0011001100111010 +0011001110001010 +0100000100111001 0100000100111010 0100000100111011 0100000100110000 0001001000001011 0001001000001010 -0100001001011111 -0100000010000110 -0100001101011011 -1001000001111111 +0100001000011111 +1111111100001110 +0100111101101101 +0100001101011100 +1001000001111101 0000000000101101 0010010000000001 -0100001101001011 -0100101101001101 -0100110101011110 -0100000010000110 +0100001101001100 +0100110001001110 +0101111100001110 +0100111001101110 0101000001111110 1111111111010000 1001000001111110 0000000000001010 0010110000111011 -1001000001111111 +1001000001111101 0000000000110000 0010010000000100 -0101000000111101 -0100000010000110 +0100110001001101 +0101111100001101 0100001100001111 0011110000101011 -1001000011110010 +1001000011111111 0000000001111000 -0100000010000111 +0000000000000001 0010001111111000 -0100000000111101 -0100000010001000 +0100111100001101 +0101001100101101 0100001100001111 0100000001111010 0000000000111001 @@ -615,15 +657,15 @@ 0101111000001110 0101111100001110 0101111000001110 -0100110001001111 +0100101101001111 0101000000111111 1111111111010000 0101111000001111 -0100110101101100 +0100110101101011 0101001100011101 -1001001101001100 +1001001101001011 0010001111110011 -1001110001001011 +1001101101001100 0010010000000110 1110001100111111 0101001100011111 @@ -633,40 +675,40 @@ 0011110000000001 0100001100011011 0001001010110000 -0011001100111010 +0011001110001010 0100101100001111 0001001010110000 -0011001100111010 +0011001110001010 0100000100111010 0100000100111011 0100000100110000 0001001000001011 0100001000011110 -0100000010101110 +0100000000001110 1001000000111110 0010011100010000 0010100000000101 0100111000001101 0101110100001101 0101000000111101 -1110111110110000 +1110111111110000 0011110000000100 0100111000001101 0101110100001101 0101001000011101 -0100000010100110 +0100000000000110 0100110100101011 0101001100011110 0100111010000010 -0100000010101110 +0100000000001110 1001001100011111 0010010000000100 0001001010110000 -0011001100101110 +0011001101111110 1001001100001111 0010000000000010 0100101110000010 -0100000010101110 +0100000000001110 0100000100111011 0100000100110000 0001001000001011 @@ -674,13 +716,13 @@ 0001001000001001 0100111100001010 0001001010110000 -0011001101000110 +0011001110010110 0100111100001001 0001001010110000 -0011001101000110 +0011001110010110 0100111100001011 0001001010110000 -0011001101000110 +0011001110010110 0100111100001110 0101101000001011 1001001100011010 @@ -694,15 +736,15 @@ 0011010000001011 0100111000001111 0001001010110000 -0011001101001110 +0011001110011110 0100101100001111 0001001010110000 -0011001101001110 +0011001110011110 0100100100001111 0001001010110000 -0011001101001110 +0011001110011110 0100100110000010 -0100000010101110 +0100000000001110 0100000100111001 0100000100111010 0100000100111011 @@ -721,71 +763,73 @@ 0000000000000000 0100000100110000 0100001000011110 -0100000010101110 +0100000000001110 1001000000111110 0010011100010000 0010100000000101 0100111000001111 0101111100001111 0101000000111111 -1110111110110000 +1110111111110000 0011110000000100 0100111000001111 0101111100001111 0101001000011111 -0100000010100110 +0100000000000110 0100111100101111 0101001100011110 0100111010000010 -0100000010101110 +0100000000001110 0001001010110000 -0011001100111010 +0011001110001010 0100000100110000 0100011000011111 0000000000000010 0001001010110000 -0011001100111010 +0011001110001010 0100000100110000 -0100000000111110 -0100000010000110 -0011110000000110 +0100001100001101 +0011110000000111 0101111100001100 -0100110111001100 +0100111011001100 0000000000000000 0101001100011111 0100111110000010 -0100000010101100 -0100111001101101 -0101001100011110 +0100000000001100 +0101001100011101 +0100001000011111 +1111111100001110 +0101110100001111 +0100111101101110 0100001000011111 -0100000010101100 +0100000000001100 0100001000011100 -0100000010110000 -1001001101001101 -0010001111110010 -0100110000001110 -0101111100001110 -0100000011111110 +1111111100001000 +1001001101001110 +0010001111101111 +0100110000001101 +0101111100001101 +0100000011111101 0000000000100000 0000000000000000 0101001100011111 0100111110000010 -0100000010101100 +0100000000001100 0101001000011111 -0100000010110000 -0100110111001111 +1111111100001000 +0100111011001111 0000000000000000 0100001000011110 -0100000010110000 -0100000000111111 -0100000010000110 +1111111100001000 +0100001000011111 +1111111100001110 0001001010110000 -0011001101100100 +0011001110110100 0101111100001111 0101001000011111 -0100000010110010 +1111111100000110 0100001010011111 -0100000010110100 +0100000000010000 0000000000000000 0100000100110000 0001001000001011 @@ -810,7 +854,7 @@ 0100000000111010 0000000000001010 0001001010110000 -0011111011111000 +0011111100111000 0101000001111110 0000000000110000 0100111011001000 @@ -819,7 +863,7 @@ 0100000000111010 0000000000001010 0001001010110000 -0011111011111000 +0011111100111000 0100110000001111 0101001100011001 1001001100001100 @@ -868,10 +912,10 @@ 1100001100010010 0001000000001111 0001001010110000 -0011011010100000 +0011011011111000 0100101100001111 0001001010110000 -0011011010100000 +0011011011111000 0100000100111011 0100000100110000 0001001000001011 @@ -881,10 +925,10 @@ 0001000110001110 0100111000001111 0001001010110000 -0011011010111000 +0011011100010000 0100101100001111 0001001010110000 -0011011010111000 +0011011100010000 0100000100111011 0100000100110000 0001001000001011 @@ -895,100 +939,102 @@ 0001001000000100 0101001100111111 1001000000111111 -0000000001001011 +0000000001001100 0010100000000010 0100000000110000 -0011101110001110 +0011101111110000 0101111100001111 0100111100010000 -0011011100010000 -0011011110100110 -0011011110101110 -0011011110110110 -0011011110111110 -0011011111011100 -0011011111110000 -0011011111111100 -0011101110001010 +0011011101101000 0011100000000000 +0011100000001000 +0011100000001110 +0011100000011010 +0011100000111000 +0011100001001010 +0011100001010110 0011100000010010 -0011100000100000 -0011100000101100 -0011100001000110 -0011100001010000 -0011100001011000 -0011100001100000 -0011100001111000 -0011100010010110 -0011100010100010 -0011100010111000 -0011100011001110 -0011100011010110 -0011101110001110 -0011101110001110 -0011100011011010 -0011100011100000 -0011100011111100 -0011100100101000 -0011101110001110 -0011100100111100 -0011100101000100 -0011100101001000 -0011100101010010 +0011100001011010 +0011100001101100 +0011100001111010 +0011100010000110 +0011100010100000 +0011100010101010 +0011100010110010 +0011100010111010 +0011100011010010 +0011100011110000 +0011100100000000 +0011100100010110 +0011100100101100 +0011100100110100 +0011101111110000 +0011101111110000 +0011100100111000 +0011100100111110 0011100101011010 -0011100101100000 -0011100101100110 -0011100101101100 -0011100101110000 -0011100101111010 0011100110000110 -0011100110010000 +0011101111110000 +0011100110011010 0011100110100010 +0011100110100110 +0011100110110000 0011100110111000 0011100110111110 -0011100111011110 -0011100111100010 -0011100111101100 -0011100111110010 -0011100111111000 -0011100111111110 -0011101000000100 -0011101000001010 -0011101000010000 -0011101000010110 -0011101001010100 -0011101001011100 +0011100111000100 +0011100111001010 +0011100111001110 +0011100111011000 +0011100111100100 +0011100111101110 +0011100111111010 +0011101000001100 +0011101000010010 +0011101000110010 +0011101000110110 +0011101001000000 +0011101001000110 +0011101001001100 +0011101001010010 +0011101001011000 +0011101001011110 +0011101001100100 0011101001101010 -0011101001110000 -0011101001110100 -0011101001111110 -0011101010001100 -0011101010100010 +0011101010101000 +0011101010110000 0011101010111110 -0011101011011100 +0011101011000100 +0011101011001000 +0011101011010010 0011101011100010 -0011101011100110 -0011101011110110 -0011101100000000 -0011101100001100 -0011101100100000 -0011101100101110 -0011101100111110 -0011101101010010 -0011101101101110 +0011101011111000 +0011101100010100 +0011101100110010 +0011101100111000 +0011101100111100 +0011101101010000 +0011101101011010 +0011101101100110 0011101101111010 +0011101110001000 +0011101110011000 +0011101110101100 +0011101111001000 +0011101111010100 +0011101111101000 0100001110010010 -0100000010000100 +0100000000000100 0100000000110000 -0011101110001110 +0011101111110000 0101011010100110 0000000000000010 -0100000000110000 -0011101110001010 +0011110000000010 1000011010100110 0000000000000010 +0001001010110000 +0011001101111110 0100000000110000 -0011101110001010 +0011101111110000 1100001000110010 0100011000001110 0101001100101110 @@ -1003,25 +1049,24 @@ 0000000100111010 0000000000000000 0100000000110000 -0011101001010000 +0011101010100100 0100011000001111 0101001100101111 0100111100101100 0100011000101010 0001001010110000 -0011111100010100 +0011111101010100 0100110010001111 0000000000000000 -0100000000110000 -0011101110001010 +0011111111100100 0001001010110000 -0011001100101110 +0011001101111110 0001001010110000 -0011011000101100 +0011011010000100 0100000000110000 -0011101110001110 +0011101111110000 0100011000101111 -0011110010010000 +0011110010010010 0100011000101101 0100011000001110 0101001100101110 @@ -1030,124 +1075,126 @@ 0100110110001110 0000000000000000 0100000000110000 -0011101110001110 +0011101111110000 0001001010110000 -0011001100101110 +0011001101111110 0100011000001110 1001111110000110 0000000000000000 0011010000010000 0011110000001011 0001001010110000 -0011001100101110 +0011001101111110 0100011000001110 1001011000101111 0011010000001010 0011110000000101 0001001010110000 -0011001100101110 +0011001101111110 0100011000001110 1001011000101111 0010000000000100 0100001110011110 0000000000000000 0100000000110000 -0011101110001110 +0011101111110000 0100001110001110 0000000000000000 0100000000110000 -0011101110001110 +0011101111110000 0001001010110000 -0011001100101110 +0011001101111110 0001001010110000 -0011011010111000 -0011110001110000 +0011011100010000 +0011110001110010 0001001010110000 -0011001010110110 +0011001100010100 0100000000110000 -0011101110001110 +0011101111110000 0001001010110000 -0011010111011000 +0011011000101100 0100000000110000 -0011101110001110 +0011101111110000 0100011000101110 1001001100001110 0011100000000010 0100000000110000 -0011101110001110 +0011101111110000 1110001100111110 0100111010000110 0000000000000000 0101001110010110 0000000000000000 0100000000110000 -0011101110001110 +0011101111110000 0100001000010101 -0100000010110100 +0100000000010000 0100010100001011 0101101100001011 0101001000011011 -0100000010100110 +0100000000000110 0001001010110000 -0011001100101110 +0011001101111110 0100111110001011 0000000000000000 0101001100010101 0100010110000010 -0100000010110100 +0100000000010000 0100000000110000 -0011101110001110 -0100011000001110 +0011101111110000 0100011000101111 0101111100001111 0101001000011111 -0100000010100110 -0011110001111101 +0100000000000110 +0100111110100110 +0000000000000000 +0100000000110000 +0011101111110000 0001001010110000 -0011001100101110 +0011001101111110 0100111100001011 0001001010110000 -0011001100101110 +0011001101111110 0100101100001110 0101111000001110 0101001000011110 -0100000010100110 +0100000000000110 0100000000110000 -0011101100111000 +0011101110010010 1001001110000110 0000000000000000 0010010000000100 0100001110000110 0000000000000000 0100000000110000 -0011101110001110 +0011101111110000 0100001110010110 0000000000000000 0100000000110000 -0011101110001110 +0011101111110000 0001001010110000 -0011001100010100 +0011001101100100 0100000000110000 -0011101110001110 +0011101111110000 0100001100001111 0011110000111000 0100001000011111 -0100000010101110 -0011110001111100 +0100000000001110 +0011110001110111 0001001010110000 -0011001101000110 +0011001110010110 0100111100001011 0001001010110000 -0011001100101110 +0011001101111110 1001001100001111 0010010000000010 0100000000110000 -0011101110001110 +0011101111110000 1000001100100111 0100101110000010 -0100000010101110 +0100000000001110 0100000000110000 -0011101110001110 +0011101111110000 0100001000011110 1111111100000000 0100111000001111 @@ -1167,131 +1214,126 @@ 0001000000001110 0100111000001111 0001001010110000 -0011001100111010 +0011001110001010 0100000000110000 -0011101110001110 +0011101111110000 0001001010110000 -0011001100101110 +0011001101111110 0001001010110000 -0011011011011000 +0011011100110000 0100000001111111 0000000000100000 0001001010010010 0100000000000000 0100000000110000 -0011101110001110 +0011101111110000 0001001010110000 -0011010001010100 +0011010010100110 0100000000110000 -0011101110001110 +0011101111110000 0100001100001111 0011111111101100 0100001100011111 0001001010110000 -0011010100000100 +0011010101011000 0100000000110000 -0011101110001110 +0011101111110000 0001001010110000 -0011101110011100 +0011101111111110 0100000000110000 -0011101110001110 +0011101111110000 0001001010110000 -0011010000000000 -0011110100010111 +0011010001010000 +0011110100011001 0001001010110000 -0011010110100100 -0011110100010100 +0011010111111000 +0011110100010110 0001001010110000 -0011010111001110 -0011110100010001 +0011011000100010 +0011110100010011 0100001100011111 0011111111011000 -0100000000111111 -0100000010000110 +0100001000011111 +1111111100001110 0001001010110000 -0011000110011010 -0011110100001010 +0011000110101100 +0011110100001100 0100001000011011 0100000000000000 0001001010110000 -0011001100101110 +0011001101111110 0001001010001011 -0011110100000100 +0011110100000110 0001001010110000 -0011001101000110 +0011001110010110 0100111110000010 -0100000010101110 -0011110011111111 -0100011000001110 -0100011000101111 -1111000000111111 +0100000000001110 +0011110100000001 +0100011000101110 +1111000000111110 1111111111111110 -0101001000011111 -0100000010101010 -0100111110101110 +0100111010100110 0000000000000000 -0011110011110110 +0011110011111011 0001001010110000 -0011001100101110 +0011001101111110 0100111100001011 0001001010110000 -0011001100101110 +0011001101111110 0100101100001110 1111000000111110 1111111111111110 -0101001000011110 -0100000010101010 -0011110011000000 +0011110011000011 0100001000011111 -0100000010110100 -0011111110110001 +0100000000010000 +0011111110110110 0001001010110000 -0011001100101110 +0011001101111110 0100111100000101 0001001010110000 -0011001100101110 +0011001101111110 0100001000011011 -0100000010101110 +0100000000001110 0001001010110000 -0011001101001110 +0011001110011110 0100010100001111 0001001010110000 -0011001101001110 +0011001110011110 0100101100001111 0001001010110000 -0011001101001110 -0011110011011000 +0011001110011110 +0011110011011111 0100001100011111 0011110000000010 0001001010110000 -0011001100101110 +0011001101111110 0001001010110000 -0011010100111110 -0011110011010001 +0011010110010010 +0011110011011000 0100011100011111 0000000000000010 -0011111110010111 +0011111110011100 0100011100011111 0000000000001000 -0011111110010100 +0011111110011001 0100011100011111 0000000000001110 -0011111110010001 +0011111110010110 1110001110110110 0000000000000000 -0011110011000101 +0011110011001100 1110011010100110 0000000000000010 -0011110011000000 +0011111011011010 1111011010100110 0000000000000010 -0011110010111101 +0011111011010111 1101011010100110 0000000000000010 -0011110010111010 +0011111011010100 1100001000110010 0001001010110000 -0011001100101110 +0011001101111110 0100111110000010 0000000100110010 0100011000000100 @@ -1313,41 +1355,42 @@ 0001000010001011 0001000110001011 0001001010110000 -0011111101001010 +0011111110001010 0100110110000100 0000000000000000 0100110010000110 0000000000000000 1101001000110010 -0011110010011101 +0011110010100100 0001001010010010 0100000000000010 0100111101001111 -0011111101100010 +0011111101100111 0100000001111111 0000000000001101 0001001010010010 0100000000000000 0100000001111111 0000000000001010 -0011111101100101 +0011111101101010 0101011010100110 0000000000000000 -0011110010001111 +0011110010010110 0001000100100110 -0011110010001101 +0011110010010100 0100011000001011 0001001010100110 0100111110001011 0000000000000000 -0011110010001000 +0011110010001111 0100011000001011 0101001100101011 0100101100101111 0001001010100110 0100111110001011 0000000000000000 -0011110001111111 +0100000000110000 +0011100000010010 0100011000001011 0101001000101011 0100011000011110 @@ -1389,70 +1432,72 @@ 0000000000000011 0000000000000000 0001001010110000 -0011001101011010 -0011110001010110 +0011001110101010 +0011110001011100 0001000010100110 -0011110001010100 +0011110001011010 0001001010110000 -0011001100101110 +0011001101111110 0100111100001011 0001001010110000 -0011001100101110 -0101111110001011 +0011001101111110 +0100101100001110 +0101111000001110 +0101111110001110 0000000000000000 -0011110001001100 +0011110001010000 0001001010110000 -0011001100101110 +0011001101111110 0001001010110000 -0011010110001010 -0011110001000111 +0011010111011110 +0011110001001011 0001001010110000 -0011001100101110 +0011001101111110 0101111100001111 0101011000001111 0100111100101111 -0011111100001010 +0011111100001100 0100011000011011 0000000000000010 0100011000101111 0001001010110000 -0011001100111010 +0011001110001010 0100011010100110 0000000000000100 0100101110000110 0000000000000010 -0011110000110111 +0011110000111011 0001001010110000 -0011001100101110 +0011001101111110 0100011000001110 1001111110000110 0000000000000000 -0011010000110001 +0011010000110101 0011110000000101 0001001010110000 -0011001100101110 +0011001101111110 0100011000001110 1001011000101111 -0011010000101011 +0011010000101111 0100111110001110 0000000000000000 -0011110000101000 +0011110000101100 0100001000011011 1111111100000000 0011110000000100 0100101100101111 0001001010110000 -0011011000101100 +0011011010000100 1000001100101011 1001011000001011 0010111111111010 -0011110000011110 +0011110000100010 0100001000011011 1111111100000000 0011110000001000 0100101100101111 0001001010110000 -0011011011011000 +0011011100110000 0100000001111111 0000000000100000 0001001010010010 @@ -1460,23 +1505,27 @@ 1000001100101011 1001011000001011 0010111111110110 -0011110000010000 +0011110000010100 0100011000101110 1110001100111110 0101001100011110 0100111010000110 0000000000000000 -0011110000001010 +0011110000001110 0100011000001111 0101001100101111 0100011000101100 0100111100101010 0001001010110000 -0011111100010100 +0011111101010100 0100111010001111 0000000000000000 +0100000000110000 +0011100000010010 0001001010110000 -0011001100101110 +0011001101111110 +0100111110000010 +0100000000001010 0100000100110100 0100000100110101 0100000100111000 @@ -1486,7 +1535,7 @@ 0100000100110000 0001001000001011 0001001010110000 -0011001100101110 +0011001101111110 0100111100001011 1001000000111111 0100111000100000 @@ -1494,74 +1543,55 @@ 0101000000111111 1011000111100000 0001001010110000 -0011011011110010 +0011011101001010 0011110000010100 1001000000111111 0010011100010000 0011100000001000 0100001000011111 -0100000010101110 +0100000000001110 0001001010110000 -0011001101001110 +0011001110011110 0101101100001011 0101000000111011 -1110111110101000 +1110111111101000 0011110000000111 0100001000011111 -0100000010101110 +0100000000001110 0001001010110000 -0011001101001110 +0011001110011110 0101101100001011 0101001000011011 -0100000010110010 +1111111100000110 0100101110100010 -0100000010101110 +0100000000001110 0100000100111011 0100000100110000 -0100001110000010 -0100000010000100 +0111001101101101 +0011010001110000 +0110100001110100 +0000000000100001 0100001000010110 1111111100000000 0100001000010111 1111111100000010 -0100001010010010 -1111111100000100 -0100000010100110 -0100001010010010 -1111111100000110 -0100000010110010 -0100001010010010 -1111111100001000 -0100000010110000 +0100001110000010 +0100000000000100 +0100001110010010 +0100000000001010 0100000010110010 0010011100010000 -0100000010101110 +0100000000001110 0100001110010010 -0100000010110100 +0100000000010000 0100001110000010 -0100000010101100 +0100000000001100 0100001110000010 -0100000010101010 -0100001110000010 -0100000010101000 -0100000000111111 -0100000000000100 -0100001111001111 -0000000000000000 -0101001100011111 -1001000000111111 -0100000010000100 -0010001111111010 +0100000000001000 0100000000111111 -0100000010000110 -0100001111001111 -0000000000000000 -0101001100011111 -1001000000111111 -0100000010100110 -0010001111111010 +0011110001000010 0001001010110000 -0011000111000100 +0011000110101100 0100000100110000 0001001000001011 0001001000001010 @@ -1572,41 +1602,41 @@ 0100111000011111 0011110000100010 0100001000011110 -0100000010101110 +0100000000001110 1001111000001001 0010110000000101 0100111000001111 0101111100001111 0101000000111111 -1110111110110000 +1110111111110000 0011110000000100 0100111000001111 0101111100001111 0101001000011111 -0100000010100110 +0100000000000110 0100111100101011 0100111000001111 0101001100011111 0100111110000010 -0100000010101110 +0100000000001110 1001101100001010 0010110000000110 0100101100001111 0101000000111111 1011000111100000 0001001010110000 -0011011011110010 +0011011101001010 0011110000001000 0001001010110000 -0011001101001110 +0011001110011110 0100101100001111 0101111100001111 0101001000011111 -0100000010110010 +1111111100000110 0100111110100010 -0100000010101110 +0100000000001110 1001001110000010 -0100000010000100 +0100000000000100 0010011111011011 0100000100111001 0100000100111010 @@ -1756,12 +1786,14 @@ 0110011101100101 0110110100100000 0110010001101111 +0110010100100000 +0110100001100011 +0010000001101111 +0101101100000000 +0011101000100000 +0111011000100000 +0111001001100001 0000000000100000 -0010000001011011 -0010000000111010 -0110000101110110 -0010000001110010 -0000000000000000 0000000000000000 0010011100010000 0010011100110000 @@ -1942,7 +1974,7 @@ 0101001100011010 1101001000111101 0001001010110000 -0011111011111000 +0011111100111000 0001000000001101 1011001000101101 0010100000000100 @@ -1973,7 +2005,7 @@ 0110001100001011 1101001000111000 0001001010110000 -0011111110010100 +0011111111010100 0001000000001000 1011001000101000 0010010000001000 @@ -2014,35 +2046,3 @@ 0010001111110001 0100000100110000 0001001100000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 diff --git a/msp4th/ldscript_ns430 b/msp4th/ldscript_ns430 index a950972..4345e83 100644 --- a/msp4th/ldscript_ns430 +++ b/msp4th/ldscript_ns430 @@ -219,11 +219,15 @@ SECTIONS PROVIDE (__data_end_rom = _etext + SIZEOF (.data)); } /* hard-coded addresses for on-line re-sizing of the msp4th arrays */ -__mathStackStartAddress = 0xff00; -__addrStackStartAddress = 0xff02; -__progStartAddress = 0xff04; -__progOpcodesStartAddress = 0xff06; -__cmdListStartAddress = 0xff08; +__msp4th_mathStackStartAddress = 0xff00; +__msp4th_addrStackStartAddress = 0xff02; +__msp4th_prog = 0xff04; +__msp4th_progOpcodes = 0xff06; +__msp4th_cmdList = 0xff08; +__msp4th_lineBuffer = 0xff0a; +__msp4th_lineBufferLength = 0xff0c; +__msp4th_wordBuffer = 0xff0e; +__msp4th_wordBufferLength = 0xff10; __PC_AFTER_RESET = 0x3000; __CRCDI = 0x0000; diff --git a/msp4th/ldscript_ns430_bootrom b/msp4th/ldscript_ns430_bootrom index d40a2a5..22c15e3 100644 --- a/msp4th/ldscript_ns430_bootrom +++ b/msp4th/ldscript_ns430_bootrom @@ -219,11 +219,15 @@ SECTIONS PROVIDE (__data_end_rom = _etext + SIZEOF (.data)); } /* hard-coded addresses for on-line re-sizing of the msp4th arrays */ -__mathStackStartAddress = 0xff00; -__addrStackStartAddress = 0xff02; -__progStartAddress = 0xff04; -__progOpcodesStartAddress = 0xff06; -__cmdListStartAddress = 0xff08; +__msp4th_mathStackStartAddress = 0xff00; +__msp4th_addrStackStartAddress = 0xff02; +__msp4th_prog = 0xff04; +__msp4th_progOpcodes = 0xff06; +__msp4th_cmdList = 0xff08; +__msp4th_lineBuffer = 0xff0a; +__msp4th_lineBufferLength = 0xff0c; +__msp4th_wordBuffer = 0xff0e; +__msp4th_wordBufferLength = 0xff10; __PC_AFTER_RESET = 0x3000; __CRCDI = 0x0000; diff --git a/msp4th/main.c b/msp4th/main.c index b150423..5860892 100644 --- a/msp4th/main.c +++ b/msp4th/main.c @@ -37,6 +37,12 @@ //total string length of all word names (+ 1x each) #define USER_CMD_LIST_SIZE 128 +//maximum input line length +#define LINE_BUFFER_SIZE 128 + +//maximum word character width +#define WORD_BUFFER_SIZE 32 + /* @@ -81,7 +87,7 @@ static void __inline__ eint(void){ -void init_uart(void) +static __inline__ void init_uart(void) { int16_t tmp; // chip setup for UART0 use @@ -109,20 +115,26 @@ int16_t __attribute__ ((section(".noinit"))) addrStackArray[ADDR_STACK_SIZE]; int16_t __attribute__ ((section(".noinit"))) progArray[USER_PROG_SIZE]; int16_t __attribute__ ((section(".noinit"))) progOpcodesArray[USER_OPCODE_MAPPING_SIZE]; uint8_t __attribute__ ((section(".noinit"))) cmdListArray[USER_CMD_LIST_SIZE]; +uint8_t __attribute__ ((section(".noinit"))) lineBufferArray[LINE_BUFFER_SIZE]; +uint8_t __attribute__ ((section(".noinit"))) wordBufferArray[WORD_BUFFER_SIZE]; void (*msp4th_putchar)(uint8_t); uint8_t (*msp4th_getchar)(void); -void config_default_msp4th(void) +static __inline__ void config_default_msp4th(void) { int16_t i; - mathStackStartAddress = &mathStackArray[MATH_STACK_SIZE - 1]; - addrStackStartAddress = &addrStackArray[ADDR_STACK_SIZE - 1]; - progStartAddress = &progArray[0]; - progOpcodesStartAddress = &progOpcodesArray[0]; - cmdListStartAddress = &cmdListArray[0]; + msp4th_mathStackStartAddress = &mathStackArray[MATH_STACK_SIZE - 1]; + msp4th_addrStackStartAddress = &addrStackArray[ADDR_STACK_SIZE - 1]; + msp4th_prog = &progArray[0]; + msp4th_progOpcodes = &progOpcodesArray[0]; + msp4th_cmdList = &cmdListArray[0]; + msp4th_lineBuffer = &lineBufferArray[0]; + msp4th_lineBufferLength = LINE_BUFFER_SIZE; + msp4th_wordBuffer = &wordBufferArray[0]; + msp4th_wordBufferLength = WORD_BUFFER_SIZE; for (i=0; i < MATH_STACK_SIZE; i++) { @@ -133,6 +145,9 @@ void config_default_msp4th(void) addrStackArray[i] = 0; } + lineBufferArray[0] = 0; + wordBufferArray[0] = 0; + msp4th_putchar = &uart_putchar; msp4th_getchar = &uart_getchar; } @@ -168,7 +183,6 @@ int main(void){ asm(".include \"flashboot.s\""); - dint(); init_uart(); /* @@ -182,9 +196,8 @@ int main(void){ * - any EOT character in the input ('^D', control-D, 0x04) * - any 0xff character in the input */ - config_default_msp4th(); - while (1) { + config_default_msp4th(); init_msp4th(); processLoop(); } diff --git a/msp4th/msp4th.c b/msp4th/msp4th.c index 9fe7bbc..0edb45c 100644 --- a/msp4th/msp4th.c +++ b/msp4th/msp4th.c @@ -24,10 +24,16 @@ #if defined(MSP430) #include "ns430.h" #include "ns430-atoi.h" +// our "special" pointer, direct word access to all absolute address space +#define dirMemory ((int16_t *) 0) #else // mixins to test msp4th on PC #include + +// the OS does not like direct memory addressing, something about +// segfaulting... just create a sham space for testing +int16_t dirMemory[65536]; #endif @@ -35,20 +41,15 @@ -/* - * Hard-coded constants - * - * buffer lengths don't need to be configurable, right? - */ -#define LINE_SIZE 128 -#define WORD_SIZE 32 - /* * Local function prototypes */ +void msp4th_puts(uint8_t *s); uint8_t getKeyB(void); void getLine(void); +uint8_t nextPrintableChar(void); +uint8_t skipStackComment(void); void getWord(void); void listFunction(void); int16_t popMathStack(void); @@ -60,6 +61,8 @@ int16_t lookupToken(uint8_t *x, uint8_t *l); void luFunc(void); void numFunc(void); void ifFunc(int16_t x); +void loopFunc(int16_t n); +void rollFunc(int16_t n); void pushnFunc(void); void overFunc(void); void dfnFunc(void); @@ -70,6 +73,7 @@ void printHexWord(int16_t n); void execN(int16_t n); void execFunc(void); + /**************************************************************************** * * Module-level global constants (in ROM) @@ -78,8 +82,8 @@ void execFunc(void); // The order matches the execN function and determines the opcode value. // NOTE: must end in a space !!!! -const uint8_t cmdListBi[] = - {"exit + - * / " // 1 -> 5 +const uint8_t cmdListBi[] = { + "exit + - * / " // 1 -> 5 ". dup drop swap < " // 6 -> 10 "> == hb. gw dfn " // 11 -> 15 "abs , p@ p! not " // 16 -> 20 @@ -94,8 +98,9 @@ const uint8_t cmdListBi[] = "call2 call3 call4 ndrop swpb " // 61 -> 65 "+! roll pick tuck max " // 66 -> 70 "min s. sh. neg mod " // 71 -> 75 + "echo " // 76 -> 76 }; -#define LAST_PREDEFINED 75 // update this when we add commands to the built in list +#define LAST_PREDEFINED 76 // update this when we add commands to the built in list // these commands are interps @@ -308,16 +313,14 @@ const int16_t progBi[] = { // address actually start at 10000 * Module-level global variables (in RAM) * ***************************************************************************/ -// our "special" pointer, direct word access to all address space -volatile int16_t *dirMemory; - int16_t xit; // set to 1 to kill program +int16_t echo; // boolean: false -> no interactive echo/prompt uint16_t progCounter; -uint8_t lineBuffer[LINE_SIZE]; /* input line buffer */ -uint16_t lineBufferIdx; /* input line buffer index */ -uint8_t wordBuffer[WORD_SIZE]; /* holds the currently-parsed word */ +int16_t lineBufferIdx; /* input line buffer index */ +int16_t progIdx; // next open space for user opcodes +int16_t cmdListIdx; // next open space for user word strings @@ -339,13 +342,11 @@ int16_t *addrStackPtr; #endif int16_t *prog; // user programs (opcodes) are placed here -uint16_t progIdx; // next open space for user opcodes -int16_t *progOpcodes; // mapping between user word index and program opcodes +//int16_t *progOpcodes; // mapping between user word index and program opcodes // start index into prog[] -uint8_t *cmdList; // string of user defined word names -uint16_t cmdListIdx; // next open space for user word strings + @@ -371,10 +372,10 @@ uint8_t getKeyB() { uint8_t c; - c = lineBuffer[lineBufferIdx++]; + c = msp4th_lineBuffer[lineBufferIdx++]; if (c == 0) { getLine(); - c = lineBuffer[lineBufferIdx++]; + c = msp4th_lineBuffer[lineBufferIdx++]; } return (c); @@ -388,15 +389,17 @@ void getLine() lineBufferIdx = 0; - msp4th_putchar('\r'); - msp4th_putchar('\n'); - msp4th_putchar('>'); // this is our prompt + if (echo) { + msp4th_putchar('\r'); + msp4th_putchar('\n'); + msp4th_putchar('>'); // this is our prompt + } waiting = 1; while (waiting) { // just hang in loop until we get CR c = msp4th_getchar(); - if ((c == '\b') && (lineBufferIdx > 0)) { + if (echo && (c == '\b') && (lineBufferIdx > 0)) { msp4th_putchar('\b'); msp4th_putchar(' '); msp4th_putchar('\b'); @@ -404,18 +407,27 @@ void getLine() } else if ( ((c == 255) || (c == '')) && (lineBufferIdx == 0)) { xit = 1; waiting = 0; + msp4th_lineBuffer[lineBufferIdx++] = 'x'; + msp4th_lineBuffer[lineBufferIdx] = ' '; } else { - msp4th_putchar(c); + if (echo) { + msp4th_putchar(c); + } + if ( (c == '\r') || (c == '\n') || - (lineBufferIdx >= (LINE_SIZE - 1))) { // prevent overflow of line buffer + (lineBufferIdx >= (msp4th_lineBufferLength - 1))) { // prevent overflow of line buffer + waiting = 0; + + if (echo) { msp4th_putchar('\n'); } } - lineBuffer[lineBufferIdx++] = c; - lineBuffer[lineBufferIdx] = 0; + + msp4th_lineBuffer[lineBufferIdx++] = c; + msp4th_lineBuffer[lineBufferIdx] = 0; } } - msp4th_putchar('\n'); + lineBufferIdx = 0; } @@ -453,11 +465,7 @@ void getWord(void) int16_t k; uint8_t c; - - for (k=0; k < WORD_SIZE; k++) { - wordBuffer[k] = 0; - } - + k = 0; c = nextPrintableChar(); // ignore comments @@ -477,16 +485,11 @@ void getWord(void) } } - k = 0; - wordBuffer[k++] = c; - wordBuffer[k] = 0; - - c = getKeyB(); - while (c > ' ') { - wordBuffer[k++] = c; - wordBuffer[k] = 0; + do { + msp4th_wordBuffer[k++] = c; + msp4th_wordBuffer[k] = 0; c = getKeyB(); - } + } while ((c > ' ') && (k < msp4th_wordBufferLength)); } @@ -494,7 +497,7 @@ void listFunction() { msp4th_puts((uint8_t *)cmdListBi); msp4th_puts((uint8_t *)cmdListBi2); - msp4th_puts((uint8_t *)cmdList); + msp4th_puts((uint8_t *)msp4th_cmdList); } @@ -509,7 +512,7 @@ int16_t popMathStack(void) i = *mathStackPtr; // prevent stack under-flow - if (mathStackPtr < (int16_t *)mathStackStartAddress) { + if (mathStackPtr < (int16_t *)msp4th_mathStackStartAddress) { mathStackPtr++; } @@ -608,7 +611,7 @@ void luFunc() { int16_t i; - i = lookupToken(wordBuffer, (uint8_t *)cmdListBi); + i = lookupToken(msp4th_wordBuffer, (uint8_t *)cmdListBi); if(i){ i += 20000; @@ -616,13 +619,13 @@ void luFunc() pushMathStack(1); } else { // need to test internal interp commands - i = lookupToken(wordBuffer, (uint8_t *)cmdListBi2); + i = lookupToken(msp4th_wordBuffer, (uint8_t *)cmdListBi2); if(i){ i += 10000; pushMathStack(i); pushMathStack(1); } else { - i = lookupToken(wordBuffer, cmdList); + i = lookupToken(msp4th_wordBuffer, msp4th_cmdList); if(i){ pushMathStack(i); pushMathStack(1); @@ -637,31 +640,34 @@ void luFunc() void numFunc() { // the word to test is in wordBuffer uint16_t i; - int16_t j; + int16_t isnum; int16_t n; - // first check for neg sign i = 0; - if (wordBuffer[i] == '-') { + isnum = 0; + n = 0; + + // first check for neg sign + if (msp4th_wordBuffer[i] == '-') { i = i + 1; } - if ((wordBuffer[i] >= '0') && (wordBuffer[i] <= '9')) { + if ((msp4th_wordBuffer[i] >= '0') && (msp4th_wordBuffer[i] <= '9')) { // it is a number - j = 1; + isnum = 1; // check if hex - if(wordBuffer[0] == '0' && wordBuffer[1] == 'x'){ + if(msp4th_wordBuffer[0] == '0' && msp4th_wordBuffer[1] == 'x'){ // base 16 number ... just assume all characters are good i = 2; n = 0; - while(wordBuffer[i]){ + while(msp4th_wordBuffer[i]){ n = n << 4; - n = n + wordBuffer[i] - '0'; - if(wordBuffer[i] > '9'){ + n = n + msp4th_wordBuffer[i] - '0'; + if(msp4th_wordBuffer[i] > '9'){ n = n - 7; // compensate for lowercase digits - if (wordBuffer[i] >= 'a') { + if (msp4th_wordBuffer[i] >= 'a') { n -= 0x20; } } @@ -670,22 +676,19 @@ void numFunc() } else { // base 10 number n = 0; - while(wordBuffer[i]){ + while(msp4th_wordBuffer[i]){ n = n * 10; - n = n + wordBuffer[i] - '0'; + n = n + msp4th_wordBuffer[i] - '0'; i = i + 1; } - if(wordBuffer[0] == '-'){ + if(msp4th_wordBuffer[0] == '-'){ n = -n; } } - } else { - n = 0; - j = 0; } pushMathStack(n); - pushMathStack(j); + pushMathStack(isnum); } @@ -776,14 +779,14 @@ 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]; + while(msp4th_wordBuffer[i]){ + msp4th_cmdList[cmdListIdx++] = msp4th_wordBuffer[i]; i = i + 1; } - cmdList[cmdListIdx++] = ' '; - cmdList[cmdListIdx] = 0; - i = lookupToken(wordBuffer,cmdList); - progOpcodes[i] = progIdx; + msp4th_cmdList[cmdListIdx++] = ' '; + msp4th_cmdList[cmdListIdx] = 0; + i = lookupToken(msp4th_wordBuffer, msp4th_cmdList); + msp4th_progOpcodes[i] = progIdx; } @@ -857,7 +860,7 @@ void execFunc(){ } else { pushAddrStack(progCounter); - progCounter = progOpcodes[opcode]; + progCounter = msp4th_progOpcodes[opcode]; } @@ -1021,7 +1024,7 @@ void execN(int16_t opcode){ break; case 27: // depth ( -- n ) \ math stack depth - pushMathStack((int16_t *)mathStackStartAddress - mathStackPtr); + pushMathStack((int16_t *)msp4th_mathStackStartAddress - mathStackPtr); break; case 28: // .h ( a -- ) @@ -1065,7 +1068,7 @@ void execN(int16_t opcode){ break; case 38: // pwrd ( -- ) \ print word buffer - msp4th_puts((uint8_t *)wordBuffer); + msp4th_puts(msp4th_wordBuffer); break; case 39: // emit ( c -- ) @@ -1242,7 +1245,7 @@ void execN(int16_t opcode){ case 66: // +! ( n addr -- ) \ *addr += n i = popMathStack(); j = popMathStack(); - *(int16_t *)i += j; + dirMemory[i] += j; break; case 67: // roll ( n -- ) \ nth stack removed and placed on top @@ -1278,7 +1281,7 @@ void execN(int16_t opcode){ case 72: // s. ( -- ) \ print stack contents, TOS on right { // addr is strictly local to this block int16_t *addr; - addr = (int16_t *)mathStackStartAddress; + addr = (int16_t *)msp4th_mathStackStartAddress; while (addr >= mathStackPtr) { printNumber(*addr); addr--; @@ -1289,7 +1292,7 @@ void execN(int16_t opcode){ case 73: // sh. ( -- ) \ print stack contents in hex, TOS on right { // addr is strictly local to this block int16_t *addr; - addr = (int16_t *)mathStackStartAddress; + addr = (int16_t *)msp4th_mathStackStartAddress; while (addr >= mathStackPtr) { printHexWord(*addr); msp4th_putchar(' '); @@ -1307,6 +1310,9 @@ void execN(int16_t opcode){ popMathStack(); break; + case 76: // echo ( bool -- ) \ ?echo prompts and terminal input? + echo = popMathStack(); + default: break; } @@ -1314,12 +1320,12 @@ void execN(int16_t opcode){ +/* + * Public function prototypes + */ + void init_msp4th(void) { - uint16_t i; - - xit = 0; - /* * Get addresses of user-configurable arrays from the pre-known vector * table locations. @@ -1327,33 +1333,18 @@ void init_msp4th(void) * Changing the values in the xStartAddress locations and calling * init_msp4th() again restarts the interpreter with the new layout; */ - mathStackPtr = (int16_t *)mathStackStartAddress; - addrStackPtr = (int16_t *)addrStackStartAddress; - prog = (int16_t *)progStartAddress; - progOpcodes = (int16_t *)progOpcodesStartAddress; - cmdList = (uint8_t *)cmdListStartAddress; - + mathStackPtr = msp4th_mathStackStartAddress; + addrStackPtr = msp4th_addrStackStartAddress; + xit = 0; + echo = 1; progCounter = 10000; progIdx = 1; // this will be the first opcode - - cmdListIdx = 0; - dirMemory = (void *) 0; // its an array starting at zero - - lineBufferIdx = 0; - for (i=0; i < LINE_SIZE; i++) { - lineBuffer[i] = 0; - } - - for (i=0; i < WORD_SIZE; i++) { - wordBuffer[i] = 0; - } - - getLine(); + msp4th_puts((uint8_t *)"msp4th!"); } @@ -1377,7 +1368,7 @@ void processLoop() // this processes the forth opcodes. execN(opcode - 20000); } else { pushAddrStack(progCounter); - progCounter = progOpcodes[opcode]; + progCounter = msp4th_progOpcodes[opcode]; } } // while () } diff --git a/msp4th/msp4th.h b/msp4th/msp4th.h index 62a0dce..039bd86 100644 --- a/msp4th/msp4th.h +++ b/msp4th/msp4th.h @@ -2,17 +2,25 @@ #define __MSP4TH #if defined(MSP430) -extern volatile int16_t *mathStackStartAddress asm("__mathStackStartAddress"); -extern volatile int16_t *addrStackStartAddress asm("__addrStackStartAddress"); -extern volatile int16_t *progStartAddress asm("__progStartAddress"); -extern volatile int16_t *progOpcodesStartAddress asm("__progOpcodesStartAddress"); -extern volatile uint8_t *cmdListStartAddress asm("__cmdListStartAddress"); +extern int16_t *msp4th_mathStackStartAddress asm("__msp4th_mathStackStartAddress"); +extern int16_t *msp4th_addrStackStartAddress asm("__msp4th_addrStackStartAddress"); +extern int16_t *msp4th_prog asm("__msp4th_prog"); +extern int16_t *msp4th_progOpcodes asm("__msp4th_progOpcodes"); +extern uint8_t *msp4th_cmdList asm("__msp4th_cmdList"); +extern uint8_t *msp4th_lineBuffer asm("__msp4th_lineBuffer"); +extern int16_t msp4th_lineBufferLength asm("__msp4th_lineBufferLength"); +extern uint8_t *msp4th_wordBuffer asm("__msp4th_wordBuffer"); +extern int16_t msp4th_wordBufferLength asm("__msp4th_wordBufferLength"); #else -extern volatile int16_t *mathStackStartAddress; -extern volatile int16_t *addrStackStartAddress; -extern volatile int16_t *progStartAddress; -extern volatile int16_t *progOpcodesStartAddress; -extern volatile uint8_t *cmdListStartAddress; +extern int16_t *msp4th_mathStackStartAddress; +extern int16_t *msp4th_addrStackStartAddress; +extern int16_t *msp4th_prog; +extern int16_t *msp4th_progOpcodes; +extern uint8_t *msp4th_cmdList; +extern uint8_t *msp4th_lineBuffer; +extern int16_t msp4th_lineBufferLength; +extern uint8_t *msp4th_wordBuffer; +extern int16_t msp4th_wordBufferLength; #endif /* diff --git a/msp4th/test4th.c b/msp4th/test4th.c index bd2c77a..769558a 100644 --- a/msp4th/test4th.c +++ b/msp4th/test4th.c @@ -11,18 +11,31 @@ #define CMD_LIST_SIZE 128 #define PROG_SPACE 256 #define USR_OPCODE_SIZE 32 +#define LINE_BUFFER_SIZE 128 +#define WORD_BUFFER_SIZE 32 + +/* + * Create storage for user-provided arrays, variables, and I/O function + * pointers. + */ int16_t mathStackArray[MATH_STACK_SIZE]; int16_t addrStackArray[ADDR_STACK_SIZE]; int16_t progArray[USR_OPCODE_SIZE]; int16_t progOpcodesArray[USR_OPCODE_SIZE]; uint8_t cmdListArray[CMD_LIST_SIZE]; - -volatile int16_t *mathStackStartAddress; -volatile int16_t *addrStackStartAddress; -volatile int16_t *progStartAddress; -volatile int16_t *progOpcodesStartAddress; -volatile uint8_t *cmdListStartAddress; +uint8_t lineBufferArray[CMD_LIST_SIZE]; +uint8_t wordBufferArray[CMD_LIST_SIZE]; + +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); @@ -47,11 +60,21 @@ void config_msp4th(void) { int16_t i; - mathStackStartAddress = &mathStackArray[MATH_STACK_SIZE - 1]; - addrStackStartAddress = &addrStackArray[ADDR_STACK_SIZE - 1]; - progStartAddress = &progArray[0]; - progOpcodesStartAddress = &progOpcodesArray[0]; - cmdListStartAddress = &cmdListArray[0]; + msp4th_mathStackStartAddress = &mathStackArray[MATH_STACK_SIZE - 1]; + msp4th_addrStackStartAddress = &addrStackArray[ADDR_STACK_SIZE - 1]; + + msp4th_prog = &progArray[0]; + + msp4th_progOpcodes = &progOpcodesArray[0]; + + msp4th_cmdList = &cmdListArray[0]; + + msp4th_lineBuffer = &lineBufferArray[0]; + msp4th_lineBufferLength = LINE_BUFFER_SIZE; + + msp4th_wordBuffer = &wordBufferArray[0]; + msp4th_wordBufferLength = WORD_BUFFER_SIZE; + for (i=0; i < MATH_STACK_SIZE; i++) { mathStackArray[i] = 0; @@ -61,6 +84,9 @@ void config_msp4th(void) addrStackArray[i] = 0; } + lineBufferArray[0] = 0; + wordBufferArray[0] = 0; + msp4th_putchar = &my_putchar; msp4th_getchar = &my_getchar; } @@ -69,10 +95,12 @@ void config_msp4th(void) int main(void) { - config_msp4th(); - init_msp4th(); - processLoop(); + while (1) { + config_msp4th(); + init_msp4th(); + processLoop(); + } return 0; } -- 2.25.1