ISR Context Analyzer

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

ISR Context Analyzer

Post by Jerry Messina » Sun May 21, 2023 2:46 pm

I put together a tool to analyze the ISR's in a program and make suggestions as to the required context save requirements.
It looks at the .asm file output for any sub, register, event, and system library usage of interest and reports on what it finds.

screenshot1.jpg
screenshot1.jpg (44.99 KiB) Viewed 1768 times

To use it, first comment out any existing 'save/restore' statements and compile your program.
Run IsrContext.exe, click the 'Open file...' button, browse to the .asm file location, select the file, and click 'Open'.
The analysis will run and you'll get a report similar to what's shown above...

Code: Select all

//==================================================================================================
HIGHP_ISR isr usage summary: PRODL PRODH
hdw shadow: 1
context save: 'save(PROD)'
//==================================================================================================
The section(s) outlined in '//=============' will show the results along with the proper context save statement to add to your isr(s).
It's pretty straight forward for most situtations, but if your program uses events there's a little more work involved.

Events are a form of indirect subroutine call and are setup at runtime by your code. Because of this the analyzer can't know for certain what event routines are being used where so it'll analyze all the events in your program and show the context for each event.
If events are flagged as being used in the isr summary, you have to combine the isr 'save' with the 'save' statement for the proper event.

I'm going to see if I can improve on this (and for many cases I probably can) but there will be situations where this is as good as it gets.

The program even works with vectored interrupt mode and IVT.bas, but you have to deal with the same event limitations since IVT.bas defines all ISR routines as events.

If you use it I'd appreciate any feedback since there are bound to be some situations I didn't consider.

IsrContext v0.1.0:
Attachments
IsrContext_v010.7z
(209.98 KiB) Downloaded 69 times

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: ISR Context Analyzer

Post by Jerry Messina » Sat May 27, 2023 3:39 pm

I've added a few new features to the ISR Context Analyzer and improved the scanning.

The program will now attempt to resolve event calls automatically, and if it can't it'll issue a message 'unable to locate all event assignments' to warn you of that. How well this works depends on how the events are assigned. For simple direct assignments it works pretty well, but when the event assignment isn't so straight-forward (like in ISRRX onData, or ISRTIMER) you'll have to do some analysis by looking manually through the event calls.

The program can now follow sub, function, and event calls to pretty much any depth, and I added a new 'Show All Calls' checkbox that allows you to analyzing all the procedure calls used in a program. This can get pretty lengthy if you have a large program, so I'd advise not using 'Show Details' along with it, but since all the checkboxes are active while the analysis runs you can check and uncheck them as you see fit.

If you enable 'Show All Calls' and/or 'Show All Events' you can even use IsrContext to analyze resource usage in programs that don't use interrupts, which can be handy to see the call stack, register, and system library use of routines in a program.

IsrContext v0.2.0
Attachments
IsrContext_v020.7z
(205.41 KiB) Downloaded 75 times

Post Reply