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

Function pointer with code banking

Hi
I am using Keil compiler for 8051 development.
i use function pointer throught in my program using code banking. i have 512 k of external ROM with 32 k of 16 banks defined.

i went through web and come to know that function pointer can be used with code banking but the condition is that all related files need to be kept in common area or same bank.

and also use OVERLAY.

now i have problem that it is pretty much difficult to keep all related function pointer files in one bank.

i have too many files which gives code overflow if i keep them in same bank.

please reply as soon as possible
and also explore more this OVERLAY with this function pointer and code banking.

regards
Have a nice day
Niraj Patel

Parents
  • "It would be valuable to have a tool that can analyze the source for locality of reference, and optimize the bank assignments accordingly. Currently, this process must be done purely manually."

    There are various tools around that analyse code for various "metrics"; eg,

    http://www.mccabe.com/iq.htm

    I wonder if such things might be able to provide useful information?

    Trouble is, they tend to be very expensive - so the money might be better spent in moving to an ARM or something... ;-)

Reply
  • "It would be valuable to have a tool that can analyze the source for locality of reference, and optimize the bank assignments accordingly. Currently, this process must be done purely manually."

    There are various tools around that analyse code for various "metrics"; eg,

    http://www.mccabe.com/iq.htm

    I wonder if such things might be able to provide useful information?

    Trouble is, they tend to be very expensive - so the money might be better spent in moving to an ARM or something... ;-)

Children
  • so the money might be better spent in moving to an ARM or something... ;-)

    Let me sugges a "something": a seriously pumped-up 8051. DS80C390 contiguous mode, for one, would seem to be exactly the kind of remedy for that kind of problem. It has its own little quirks, but compared to doing 8 x 32K code banking on a classic 8051, it's heaven on earth.

  • The most valuable metric would probably be inter-bank call count. I haven't thought about it in detail; maybe you also want to measure parameter space needed. But the primary metric is probably just calls out of the current bank.

    So, the tool would have a big 2D matrix, indexed by module (segment), with a count of all calls to other segments. Each segment must be assigned to a bank. Minimize the total cost by changing bank assignments to reduce the inter-bank count. For extra credit, allow manual "nailing down" of bank assignment for particular modules that have particular requirements (say, a need for speed that forces them into the common bank).

    I'm sure someone's project metrics count entry points, but it seems unlikely that they'd organize modules into groups in this manner.

    In one of my particular cases, I've only got about 90KB of code, hardly a reason to move to an ARM7 or whatever. (Not that it's a possibility, because many hundreds of thousands of deployed units exist with the current processor.) But even with a small program, it's still an annoying manual process to assign .c files to banks. Add some code, or even debug statements, the bank overflows, and the linker just quits. There's no automatic reassignment or balancing at all.

  • uVision already has a feature that can tell you most of this kind of thing. The source browser creates a database of functions and callers and callees.

    To view it...

    1. Make sure that Browse Information is enabled in the Options For Target - Output tab. Then, re-build your project.
    2. Select Source Browser from the View Menu.
    3. Select Functions from the Browser Window. This shows all the functions in your program. Click on the Uses column to sort by the number of times the function is called.
    4. Right-click on a function to change the display to show the call tree or the caller tree for that function.
    You can use the information from the source browser to figure out which functions to locate in the common area and which functions to locate in code banks.

    Note that deciding which functions go where is a difficult problem that is not easy to automate. Besides, the automation would probably fail more often than not. So, untimately, it is up to the developer.

    Jon

  • The fundamental limitation that I find with the Sourec Browser is that there's no way to export any results from it. :-(
    It all has to be done interactively in the GUI - and is all lost when you close the GUI. :-(


    MSVC used to have a command-line tool for querying their browser database ("bscdump", IIRC) - something like that would be really useful!

  • hi
    for this function pointer with code banking problem ,i come to know that OVERLAY directive can Generate table which has return address of function pointers.

    so any body know how to set this OVERLAY directive in keil?

    regards
    Niraj