??? 08/27/04 06:40 Read: times |
#76477 - RE: return address Responding to: ???'s previous message |
hi,
when i call a function from the C file the .SRC file generated shows that it uses the LJMP There are many reasons why compiler may use instruction JMP instead CALL during function call. i want that it will use LCALL instead of LJMP No, you may not force compiler for that. Let C-compiler to do things right or use ASM routines if you really need with it. so i can get the return addrress Could I ask two questions here: 1) how do you get return address? If you think that it may be done with reading of two upper values from the stack then you are wrong. For example, compiler may pass some parameters via stack; in this case you cannot be sure about what you popped from stack. As well, due hard optimization it may be that compiler groups some common used parts into separate subroutines. And the return address you popped from stack may be not actual return address but re-defined address to one of such subroutines. 2) Why? What do you need with this trick for? Could you explain please, the reason to obtain return address? Maybe we suggest you another way. For example, if you just need to know from where a function was called then just pass into it the identifier of program part: enum program_parts { PP_SETUP, PP_TEST, PP_WORK, PP_CLEANUP, PP_OFF }; void foo(int from_where) { // ... if (from_where == PP_SETUP) { // ... } // etc } void main(void) { // ... foo(PP_SETUP); // ... foo(PP_TEST); // ... // etc } Regards, Oleg |
Topic | Author | Date |
return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
How many times...? | 01/01/70 00:00 | |
RE: How many times...? | 01/01/70 00:00 | |
RE: How many times...? | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
RE: return address | 01/01/70 00:00 | |
Why does it bother you?![]() | 01/01/70 00:00 |