In MPLAB IDE, View->Disassembly Listing or View->Program Memory.
If using Program Memory view, I select the "Symbolic" tab at the bottom of the window.
For example,
Code:
void EventHandler_Remove( void )
{
unsigned char ndx;
for (ndx=0; ndx<MAX_EVENT; ndx++)
{
EV_Links[ndx] = EV_Links[ndx+1];
if (EV_Links[ndx] == 0xFF ) break;
}
return;
}
Generates 33 instruction cycles per loop plus 9 instruction cycles of overhead/setup. It could take a maximum of 537 instruction cycles to complete if the event array is full.
Code:
526: for (ndx=0; ndx<MAX_EVENT; ndx++)
6002 6ADF CLRF 0xfdf, ACCESS
6004 0E10 MOVLW 0x10
6006 5CDF SUBWF 0xfdf, W, ACCESS
6008 E21D BC 0x6044
6040 2ADF INCF 0xfdf, F, ACCESS
6042 D7E0 BRA 0x6004
527: {
528: EV_Links[ndx] = EV_Links[ndx+1];
600A 28DF INCF 0xfdf, W, ACCESS
600C 6AEA CLRF 0xfea, ACCESS
600E 0FE0 ADDLW 0xe0
6010 6EE9 MOVWF 0xfe9, ACCESS
6012 0E07 MOVLW 0x7
6014 22EA ADDWFC 0xfea, F, ACCESS
6016 50EF MOVF 0xfef, W, ACCESS
6018 6EE6 MOVWF 0xfe6, ACCESS
601A 50DF MOVF 0xfdf, W, ACCESS
601C 6AEA CLRF 0xfea, ACCESS
601E 0FE0 ADDLW 0xe0
6020 6EE9 MOVWF 0xfe9, ACCESS
6022 0E07 MOVLW 0x7
6024 22EA ADDWFC 0xfea, F, ACCESS
6026 52E5 MOVF 0xfe5, F, ACCESS
6028 50E7 MOVF 0xfe7, W, ACCESS
602A 6EEF MOVWF 0xfef, ACCESS
529: if (EV_Links[ndx] == 0xFF ) break;
602C 50DF MOVF 0xfdf, W, ACCESS
602E 6AEA CLRF 0xfea, ACCESS
6030 0FE0 ADDLW 0xe0
6032 6EE9 MOVWF 0xfe9, ACCESS
6034 0E07 MOVLW 0x7
6036 22EA ADDWFC 0xfea, F, ACCESS
6038 50EF MOVF 0xfef, W, ACCESS
603A 08FF SUBLW 0xff
603C E101 BNZ 0x6040
603E D002 BRA 0x6044
530: }
531: return;
6044 D005 BRA 0x6050
This is executed at interrupt time and looks a bit wordy. An alternative is code that does the following:
Code:
void EventHandler_Remove( void )
{
EV_Links[0] = EV_Links[1];
EV_Links[1] = EV_Links[2];
<snip>
EV_Links[15] = EV_Links[16];
return;
}
533: EV_Links[0] = EV_Links[1];
6046 C7E1 MOVFF 0x7e1, 0x7e0
6048 F7E0 NOP
534: EV_Links[1] = EV_Links[2];
604A C7E2 MOVFF 0x7e2, 0x7e1
604C F7E1 NOP
This generates 32 instruction cycles for processing the whole array. So this code has more C code but executes faster than even the minimum 1 time through the arrray using the for loop. Although I can easily read the code and what it is doing, I'm really only interested in instruction counts. If the instructions being generated for each line of C code look a bit high in count, then I usually investigate and possibly re-think what I'm doing based upon how often the code is being executed and how time critical the code is. One of the weaknesses of the PIC18F architecture is array and pointer manipulation - for example - but there are other programming methods of organizing and processing the data to avoid or mitigate those weaknesses.
Bud