CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Need help tracing an assembly call

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Grimmtooth



Joined: 16 Jul 2009
Posts: 5

View user's profile Send private message

Need help tracing an assembly call
PostPosted: Fri Aug 07, 2009 6:44 pm     Reply with quote

I'm looking to trace the c compiler's assembly structures and calls to look for speed optimization opportunities. Unfortunately, I have yet to figure out how to trace calls like the one that follows:

Code:
00848:  BCLR.B  43.0
0084A:  MOV     W6,W0
0084C:  MOV     W7,W1
0084E:  MOV     #100,W2
00850:  MOV     #0,W3
00852:  CALL    32A
00856:  ADD     W0,[W5],[W5]
00858:  ADDC    W1,[++W5],[W5]


Is there a way to search for the assembly call to 32A or find it manually? Initially, I thought it was a call to a program address, having run a search, I found that is not the case.

Anyone have suggestions how I can trace the compiler function call?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 07, 2009 7:03 pm     Reply with quote

To see the all the ASM code for the program in the .LST file, you need to
comment out the #nolist statement at the start of the .H file for your PIC.
Example:
Quote:

//////// Standard Header file for the PIC18F452 device /////////
#device PIC18F452
//#nolist

Then re-compile and look for your routine again.
Grimmtooth



Joined: 16 Jul 2009
Posts: 5

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 12:36 pm     Reply with quote

I'm using a pic24f and my header is as follows:

Code:
#include <24FJ128GA010.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOWRT                    //Program memory not write protected
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOCOE                    //Device will reset into operational mode
#FUSES ICSP2                    //ICD uses PGC2/PGD2 pins
#FUSES NOWINDIS                 //Watch Dog Timer in Window mode
#FUSES WPRES128                 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16                 //Watch Dog Timer PostScalar 1:32768
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES PR_PLL                   //Primary Oscillator with PLL
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO                  //OSC2 is clock output
#FUSES XT                       //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD

#use delay(clock=32000000)


I didn't see a #nolist preprocessor command on the list. Is this a default functionality that I need disable? Also, the assembly I am looking for is not a user-defined function, but a compiler called function used to compile a loop written in c. I am just trying to verify how it implemented the program from c.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 12:53 pm     Reply with quote

I don't have the PCD compiler, but in PCB, PCM, and PCH, the #nolist
line would be near the top of the .h file for PIC. Look in this file:
Quote:
24FJ128GA010.h
Grimmtooth



Joined: 16 Jul 2009
Posts: 5

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 5:44 pm     Reply with quote

I was able to track down the nolist command and comment it out, but it didn't change the call structure of the compiler. For example, the c expression here in assembly has 2 calls to functions, but I can't find anything relating to call 22E or call 32A.

Is there a way to single step through the assembly code instead of the c code? If so, perhaps I can follow the trace that way.

Code:
....................             data[a]-=(21*data[b]+11)/64;
0073E:  MOV     A96,W4
00740:  MUL.UU  W4,#4,W0
00742:  MOV     #862,W4
00744:  ADD     W0,W4,W5
00746:  MOV     A98,W4
00748:  MUL.UU  W4,#4,W0
0074A:  MOV     #862,W4
0074C:  ADD     W0,W4,W0
0074E:  MOV     W0,W4
00750:  MOV     #0,W3
00752:  MOV     [W4++],[W3++]
00754:  MOV     [W4++],[W3++]
00756:  MOV     W0,W2
00758:  MOV     W1,W3
0075A:  MOV     #15,W0
0075C:  MOV     #0,W1
0075E:  CALL    22E
00762:  MOV.D   W0,W6
00764:  ADD     W6,#B,W6
00766:  ADDC    W7,#0,W7
00768:  BCLR.B  43.0
0076A:  MOV     W6,W0
0076C:  MOV     W7,W1
0076E:  MOV     #40,W2
00770:  MOV     #0,W3
00772:  CALL    32A
00776:  MOV     [W5],W4
00778:  SUB     W4,W0,[W5]
0077A:  MOV     [++W5],W4
0077C:  SUBB    W4,W1,[W5]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 5:51 pm     Reply with quote

What happens if you load the .LST file and do a search for that address ?
Do you see it ?

If not, in MPLAB, go to the View menu and look at the Disassembly listing
and/or the Program Memory window.

If the code is actually there, you'll at least see it in the Program Memory
window.

However, I don't have the PCD compiler, so I can't verify this for myself.
This advice is based on the PCM and PCH compilers.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group