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

C51 libs: Where is ?C?LSTKXDATA and friends documented?

I am trying to  understand some disassembled code, and encounter instances of ?C?LSTKXDATA. Apparently, that function expects 4 bytes of data following the call instruction. And thus must adjust the stack accordingly before RETurn.

https://github.com/NationalSecurityAgency/ghidra/issues/1177

I've seen the arm.com doc page that comes up when searching for this function: http://www.keil.com/support/docs/1964.htm   But that page describes passing arguments only in registers.

Looking at the disassembly, ti does indeed look like ?C?LSTKXDATA starts by popping the return address into DPTR, and then using that pointer to access data, and then uses the incremented address to JMP "return".

But it would be nice to see actual docs on what ?C?LSTKXDATA does, how to call it, and others in that family of functions that have similar call conventions.

Thanks.

Parents
  • The 1964 page describes what it is expecting. It is just helper code the compiler opts to use to reduce code size. ie replaces repetitive or mundane code with shorter byte code sequence the called routine unpacks and executes, like p-code

    The code is unpacking DB bytes after the call, you can look at the disassembly of the actual function, or pull the function(s) from one of the libraries the linker is using, or if the linker creates this binding

Reply
  • The 1964 page describes what it is expecting. It is just helper code the compiler opts to use to reduce code size. ie replaces repetitive or mundane code with shorter byte code sequence the called routine unpacks and executes, like p-code

    The code is unpacking DB bytes after the call, you can look at the disassembly of the actual function, or pull the function(s) from one of the libraries the linker is using, or if the linker creates this binding

Children
  • > replaces repetitive or mundane code with shorter byte code sequence the called routine unpacks and executes, like p-code

    Not sure what that has to do with it. This is on a MCU with code in a ROM, so it's not going to be unpacking code and executing it. This is just a function call, but with additional data after the call site, and the return jumps over it. More in an additional reply.