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 CCS Technical Support

Find start address of functions

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



Joined: 18 Nov 2003
Posts: 14
Location: Ireland

View user's profile Send private message

Find start address of functions
PostPosted: Tue Mar 16, 2004 6:38 am     Reply with quote

Hey
i currently working on a project where i need to find the start address of functions. The easiest way would be to use function pointers however iam stuck with the older versions of the ccs compiler. However i have wrote a program whhich searches for a string in a function where the start of the string is at the start address of the function, this works fine but i can run in to some problems due to how the compiler works, for example sometimes it puts some operations in before the string therefore making my program useless, i was wondering if there is another way i could handle this problem.

void taskA()
{
char string[12] = "TASK_FIND_A"; //SEARCH STRING
}

The above shows the format of the functions i need to find, if i for example put in a printf statementm the compiler does something weird (in the symbols file it doesn't seem to have compiled the function) which i can't understand and makes the search string program useless

void taskA()
{
char string[12] = "TASK_FIND_A";

printf(lcd_putc, "%c", char_in);
}

can anyone tell what is happening here?
Thanks
Michael
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 16, 2004 11:27 am     Reply with quote

Well, you didn't say what version of the compiler you have,
so I'll assume that by "older" you mean vs. 2.7xx.

In the example below, I used PCM vs. 2.734. I used #org
statements to set the starting address of two sample functions.

Code:
#include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#org 0x200, 0x2FF
void func1(void)
{
char c;
c = 0x55;
}

#org 0x300, 0x3FF
void func2(void)
{
char i;
i = 0xAA;
}

//==================================
void main(void)
{
func1();
func2();

while(1);
}


This code produces the following .LST file, which puts the
start of the functions at the specified addresses.
Code:

.................... void func1(void)
.................... {
.................... char c;
.................... c = 0x55;
*
0200:  MOVLW  55
0201:  MOVWF  21
0202:  BCF    0A,3
0203:  BCF    0A,4
0204:  GOTO   00C
.................... }
.................... 
.................... #org 0x300, 0x3FF
.................... void func2(void)
.................... {
.................... char i;
.................... i = 0xAA;
*
0300:  MOVLW  AA
0301:  MOVWF  21
0302:  BCF    0A,3
0303:  BCF    0A,4
0304:  GOTO   00D
.................... }
.................... 
.................... 
.................... //===========================
.................... void main(void) 
.................... { 
*
0004:  CLRF   04
0005:  MOVLW  1F
0006:  ANDWF  03,F
0007:  MOVLW  9F
0008:  MOVWF  04
0009:  MOVLW  07
000A:  MOVWF  00
.................... func1();
000B:  GOTO   200
.................... func2();
000C:  GOTO   300
.................... 
.................... while(1);
000D:  GOTO   00D
.................... }
.................... 
000E:  SLEEP
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