This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to give starting address of a function

I want to knwo How can I give starting address of a fucntion.
I want to know for both a function written in C and even in assembly.

The reason I require is that, in P89V51RD2 when I use to do IAP at that time precaution require is that the function which is used for IAP should not be in the 0x0000 to 0x2000 location. and I dont know how compiler is going to assign the start address so what I have to do is that I have to start downloading code form 0x2000H location. so my 8K memory is waste..
But If I can assign the start adrress then I can easly locate the the function below 0x2000H location.

So I want to know for both a Function written in C and even in Assemble.

  • The name of the function represents it's address, so it is very easy to find out the start address.

    But in your case, it doesn't matter how you programatically finds the location of a function. You can manually look in the map file to make sure that the function isn't in the first 8kB code space.

    And if you place the function in a separate segment, you will be able to configure the linker to link your function last in the application. As long as your program is big enough, your function will be located way after the 0x2000 address.

  • Thax a lot for your reply.

    But may I know what does mean different segment. When I am writing a assembly code at that time we are assigning some segmnet but how in C??

  • When we are defining a variable at that time we can fixe its location using _at_ keyword.

    Same way how can I fixe the address of fucntion written C and assembly??

  • Each .c file is normally its own segment with C51, typically called ?PR?file.

    See the BL51 linker directive CODE or the LX51 directive SEGMENTS for placing a particular segment at a particular address.

    You can also use the linker to locate variables. The _at_ keyword is an extension intended for convenience. But it's really the linker's job to select addresses for code and data.