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

functions variable mapping?

As I can see, the keil compiler doesnt use regular stack for functions, and all the local variables inside functions are mapped in global memory.
Is there a way, to make it behaive like a normal program should? I.E - create a local variables in ram,and destroy them, when the function ends?
Thank you.

Parents
  • The Application Note describes a way to use tables of function pointers without having to resort to manual OVERLAY directives:

    "The C51 Compiler and BL51 Linker work in combination to make overlaying the variable space of function easy when you use tables of function pointers. However, you must declare the pointer tables appropriately. If you do this, you can avoid using the OVERLAY directive." (my emphasis).

    Typically, function pointers used to implement a state machine would be used in tables.

    "Still ... function pointers are messy. They make the program very difficult to understand for anyone trying to maintain the program."

    I disagree.
    A large state machine implemented with switch states can be very cumbersome to maintain; function pointers can be very beneficial here!

    Whether that makes them a good idea on an 8051, though, remains open to question...

Reply
  • The Application Note describes a way to use tables of function pointers without having to resort to manual OVERLAY directives:

    "The C51 Compiler and BL51 Linker work in combination to make overlaying the variable space of function easy when you use tables of function pointers. However, you must declare the pointer tables appropriately. If you do this, you can avoid using the OVERLAY directive." (my emphasis).

    Typically, function pointers used to implement a state machine would be used in tables.

    "Still ... function pointers are messy. They make the program very difficult to understand for anyone trying to maintain the program."

    I disagree.
    A large state machine implemented with switch states can be very cumbersome to maintain; function pointers can be very beneficial here!

    Whether that makes them a good idea on an 8051, though, remains open to question...

Children
No data