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

Load function in assembly

If I have the address of particular function, is it possible load the function in assembly?

I understand that usually the function is loaded as

LCALL _function

but I was wondering whether it is possible to load the function with its address?

Appreciate anyone who can offer me advise on this. Thank you.

Parents
  • Basicly, the return address and the function pointer are loaded onto the stack and then a RET instruction causes the CPU to pop the address of the function pointer into the PC.

    That technique has no excuse being used on the 8051, which has a perfectly fine "computed goto" instruction:

           JMP @A+DPTR
    

    There are platforms where indeed you need such stack hacks to do a computed jump, but the 8051 is, fortunately, not one of them.

Reply
  • Basicly, the return address and the function pointer are loaded onto the stack and then a RET instruction causes the CPU to pop the address of the function pointer into the PC.

    That technique has no excuse being used on the 8051, which has a perfectly fine "computed goto" instruction:

           JMP @A+DPTR
    

    There are platforms where indeed you need such stack hacks to do a computed jump, but the 8051 is, fortunately, not one of them.

Children