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

Calling function from library without lcall.

I have been programming in ASM some project, which, together with the source code will have to transfer to the customer. But this project contains some of the functions source code which I do not want give to customer. I went as follows: i create a library and needed for me function connect to my project with

EXTERN CODE(function name)

, and calling this function by

lcall function name

. But this solution is not best. When i call function from library many times each call using 5 CLK for lcall and 4 CLK fro ret, and this slows the program.
Maybe somebody knows call function from library without lcall and ret instruction. In C++(on PC),example, i using

inline

statement, maybe something similar is ASM(or Ax51).

Thanks for all!.

  • maybe something similar is ASM(or Ax51)

    There is something similar to inline in assembler. It's called a macro, but it implies that the source code for the macro is available.
    You can try and replace instructions in a macro with DB statements to make reverse engineering more difficult. But this way you'll loose the linker's relocation services.
    I'm afraid your options are very limited.

  • What agreements did you do with the customer? Are they agreeing to just receive some of the source code?

  • I know, about macro, but this not suitable, You are right, it implies that the source code for the macro is available.

    About second your proposal:

    You can try and replace instructions in a macro with DB statements to make reverse engineering more difficult. But this way you'll loose the linker's relocation services.
    I'm afraid your options are very limited.
    

    .
    an be due to poor knowledge of English, I not fully understand, could you give me an example please.
    Thanks for the help anyway!

  • What agreements did you do with the customer? Are they agreeing to just receive some of the source code?
    

    With my customer, i easy to decide this issue, but for me just interesting, how i can use object files(created with library) in my project with out lcall statement? place this copy of function on each place where it's function will be called.

  • due to poor knowledge of English, I not fully understand, could you give me an example please

    Basically use instruction opcodes instead of instruction mnemonics. For example, "DB 0x14" instead of "DEC A". Obviously, you will not be able to reference variables by name. You'll have to use hard-coded addresses instead.

  • You don't really have a choice.

    If the functions are so time-critical that the time for call/return matters, then I wonder if you haven't drawn the divisor line at the wrong place.

    If the function is seldom called, then call/return times shouldn't matter.

    If function is called from a tight loop, then you should consider including the loop with the code.

    An issue here - what function is so small that the call/return times represents a significant amount of time, and still complex enough that you want to protect the source code?

    Using db statements will not be a good idea since the bytes must either use 100% relative references, or perform absolute references to already fixed locations.

  • In fact, I'm probably too carefully described the whole problem, and it creates more questions than answers.
    The question is: Is it possible to call a function that has the label

    func_name:
    ;function source code
    func_end:
    

    ,
    without EXTRN (func_name) and Lcall statement, if this function was translated to object files.
    Most likely, this question relates directly to the linker, but i don't find like this problems, and any questions. Also i fully understand that this problem is not typical, and does not arise for most users. But this relay situation and maybe have some real reasons.

    Thanks to all who participate in the discussion!

  • If the question is "is the inlining functionality present in the linker" then the answer is "no."
    Normally, a linker is designed to resolve references, calculate and fill in addresses, and maybe perform some optimizations such as removal of unreferenced objects and replacement of far jumps with relative ones. Inlining is normally done by a compiler.