After much experimenting (which included looking at the ucSim source
code), I have determined that the 'configuration memory' of simulated
elements (e.g. simif, uart, ports, etc.) is not accessible through the
simif interface. I'm not quite sure *what* that stuff is actually
supposed to be used with, but the only clue I have is that it is perhaps
intended for use with 'set hardware' commands. However, that only
appears to work at present for 8051 - any other platform's simulator
just returns "Nothing to do" when you try using "set hardware ...".
Anyway, in the end I managed to accomplish my goal of being able to
automatically measure execution speed of certain sections (e.g.
functions) of my code. I thought I would describe the method here in
case anyone finds it useful.
1. Set up breakpoints directly before and after the section of code to
be benchmarked. In my case, I set a single 'event' breakpoint to watch
for writes to a GPIO port with the command "break rom w <reg_addr>", and
at the appropriate points in my code toggled a GPIO pin on that port.
2. Add a timer with the command "timer add <name>".
3. Add a 'command' to the previously-added breakpoint. This will execute
a given command string every time that breakpoint is hit. The trick here
is to add multiple commands (separated by ';') to stop the timer, get
its value, reset it, re-start it, then continue the program: "commands
<bp_num> timer stop <name>; timer get <name>; timer set <name> 0; timer
start <name>; run". The breakpoint number can be viewed with "info
breakpoints".
With all that set up (I added the commands to a 'config' file to be
executed at start-up, with -C arg), when the program is running in the
simulator, every time it breaks I get the timer measurements (time,
cycles) printed to the console and the program automatically resumed!
The third part of the set-up was the most difficult, because breakpoint
commands are *totally* undocumented (just a stub heading is present),
and I only figured out what they were and how they worked (including
that multiple commands could be semicolon-separated) because I happened
to be browsing that part of the ucSim source code for other reasons.
As an aside, in my opinion the documentation of ucSim could be very much
improved. It is quite painful to interpret sometimes. I find that it
makes too many assumptions that the user is running the 8051 simulator,
barely acknowledges the other platforms it supports, and as I already
mentioned, some commands are completely undocumented. Hopefully this can
be rectified in future.
Regards,
Basil Hussain
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user