Welcome! Log In Create A New Profile


Flash function list

Posted by kev1953 
Flash function list
July 20, 2014 02:23PM
Hi, Is there a way to get a list of the functions stored in flash
Re: Flash function list
July 20, 2014 07:00PM
Re: Flash function list
July 21, 2014 03:10PM
Thanks, but had already tried that, I should have said it's on a BP1 board and list dose not work
tried on BP2 board and list works
Had a look using peekc, and found that I could maybe decode the BP2, but the flash on the BP1 seems to be
stored differently, any pointers please
Re: Flash function list
July 21, 2014 05:16PM
its is a good question and I will use it to explain a bit of the internals.
List does not exist in BP1 this is because the name of the function, once compiled is not saved so there is nothing to list. Unlike other 'interpreted' languages when a function is created it is compiled into a list of addresses, there is room in the BP2 to save the name but not in the BP1.

The name is actually hashed into a 32 bit number, there is a function even in the BP1 that will give a unique number related to a string: hash("hello") =0x28d19932. This would now be the name of the function hello, BP2 stores the name for convenience but the program does not need it.

To give an example this function:
function hello()
   print "hello"

Is stored as 
Address 	 Contents 	 Look up
a00032d8	9d00b7ac	....
a00032dc	9d0371c4	lhold
a00032e0	9d036198	(strlit)
a00032e4	8	        ....
a00032e8	6c6c6568	hell
a00032ec	6f	        o...
a00032f0	9d036b4c	type
a00032f4	9d0371e8	lrelease
a00032f8	9d0366f0	exit

On the BP2 there is a decompile <function name> command used for debugging, this has been left in on most releases. In the above (strlit) is a string literal, '8' is the number of bytes allocated for that string and 'type' is the function that will send it to the console. The address 0xa00032d8, where it is currently stored is part of the RAM, the (strlit) and 'type' functions are stored in Flash which is a lower address.
Sorry, you do not have permission to post/reply in this forum.