Debugging the STM8S is easy to do by dumping the contents of blocks of data within the memory map.
words
IRET SAVEC RESET RAM NVM LOCK ULOCK ADC@ ADC! WORDS .S DUMP ALLOT VARIABLE CREATE DOES> ] IMMEDIATE : ; OVERT ." $" ABORT" AFT REPEAT WHILE AHEAD ELSE THEN IF AGAIN UNTIL BEGIN +LOOP LOOP DO NEXT FOR COMPILE [COMPILE] LITERAL CALL, C, , ' [ NAME> \ ( .( ? . U. TYPE U.R .R CR SPACES SPACE KEY DECIMAL HEX <# SIGN HOLD #S # #> ERASE FILL CMOVE HERE COUNT +! DEPTH PICK 0= ABS NEGATE NOT 1+ 1- 2+ 2- 2* 2/ EXG */ */MOD M* * UM* / MOD /MOD M/MOD UM/MOD WITHIN MIN MAX < U< = DNEGATE 2DUP ROT ?DUP BG TIM BL OUT last '?KEY 'EMIT BASE - 0< OR AND XOR + UM+ I OVER SWAP DUP 2DROP DROP NIP >R R@ R> C! C@ ! @ B! 2C@ 2C! 2@ 2! EXIT EXECUTE LEAVE EMIT ?KEY TX! ?RX hi 'BOOT OUT! COLD ok
\ real programmers only use hex (or octal or binary)
https://xkcd.com/378/
https://explainxkcd.com/378/
https://www.youtube.com/watch?v=UIKGV2cTgqA
Remember octal is just like decimal - if you're missing two fingers.
: ramdump 0 $3FF dump ; \ for S003 and S103 only
Words can be decoded by:
hex
' ramdump . 9B58 ok
' called TICK gives the address of the machine code associated with the word and prints it with dot . It is always best to give your dump a spread before and after to see the full context. $ is hex and it shows the code beginning at $9B58 as 83 0 0 ...
Now look at the value before 'ramdump' and you will see it is 7 which is the number of bytes in the word 'ramdump.'
This area of flash is called the dictionary. Anything typed into eForth OS command line is interpreted immediately as a previous word command, a number or discarded. Colon begins a new word and semicolon ends it, the compiler then stores the new word in flash or RAM which then adds it to the dictionary.
\ the DUMP command needs to be fixed to show byte leading zeros and the html spacing here is bad. DUMP also displays 16 bytes per line regardless of desired length. Data shown here will vary by version.
$9B40 3F dump
9B40 64 75 6D 70 83 48 0 83 0 A CD 91 16 81 9B 3C dump_H____M____<
9B50 7 72 61 6D 64 75 6D 70 83 0 0 83 3 FF CD 91 _ramdump______M_
9B60 16 81 9B 50 A 69 6E 74 76 65 63 74 6F 72 73 83 ___P_intvectors_
9B70 80 0 83 0 7F CD 91 16 81 9B 64 6 62 75 66 66 _____M____d_buff ok
eForth is too small to store the source code so it is best to keep a text file in a project directory or folder. Using picocom the command ctrl-a ctrl-s will ask for the file name to be loaded.
In a text console I like to print out the file name to be sure.
ls /home/pi/Desktop/ForthPidrive/dumps.f
/home/pi/Desktop/ForthPidrive/dumps.f
Then I copy the details and paste it into the eForth command.
NVM or nvm (Forth doesn't care) puts the following code into Non Volatile Memory = flash. RAM then restores new input default into RAM or ram.
NVM
: ww words ;
: uniqid $4865 $0C dump ;
: eedump $4000 $27F dump ;
: optdump $4800 $0A dump ;
: ramdump 0 $3FF dump ;
: intvectors $8000 $7F dump ;
: buffer $350 $4F dump ;
: flashdump $8080 $1EFF dump ;
: gpiodump $5000 $7FF dump ;
: alldump CR uniqid CR eedump CR optdump CR intvectors CR gpiodump
CR buffer CR ramdump CR flashdump CR ;
RAM
Here CR is an eForth word equal to carriage return. eForth only has an 80 character buffer so it is required to separate long lines. Of course all commands are separated by space.
Debugging in this manner is exactly like it was done in the mid 60s to late 70s if one couldn't afford a development system or computer then the price of a house or two.
The beauty of eForth means that once the target has been blasted, one can throw away the source system like the Billion Dollar Brain (terrible movie) or in Tron, the MCP no longer is needed - End of Line.
MCP is in no way related to the 5 year old who passed the Miracle Soft exams. This is, after all, about real computing.
http://www.bbc.co.uk/news/technology-30054140
Non of this would be possible without the twisted minds of: Chuck, Thomas and C.H. Ting and others.
https://github.com/TG9541/stm8ef/wiki
https://hackaday.io/project/16097-efort ... 8s-gadgets
https://hackaday.io/project/18286-misc- ... 8-stm8s003
http://www.greenarraychips.com/home/about/bios.html