??? 12/31/08 11:50 Read: times |
#161238 - In principle this should work. Responding to: ???'s previous message |
If you write a subroutine in ASM, you would generally document:
1. The parameters used 2. The function performed and result that is returned 3. The registers and other resources that are used 4. The side-effects e.g. registers that are trashed You (or someone else) can read the documentation and call this subroutine by just obeying the rules. A C compiler uses exactly the same process. You will find how parameters are passed, registers and memory used etc from the C compiler manual. The actual function signature is documented by the C library. You just obey the rules. It is normally a C program that would link with an ASM function. Providing all the rules are followed then everything is fine. An ASM program can link with compiled C functions in principle. You follow the rules. The linker must be able to understand the .OBJ modules from both C and ASM. It is a lot easier to use a compiler and assembler from the same toolset. Or you and your assembler must understand the compiler generated ASM. Neither method is for the faint-hearted. You need an intimate knowledge of both (a) your ASM style and (b) the C compiler style. When (a) is unknown or undocumented you will have little success. David. |