- Compile C code and get the OBJ file
- Call the C/C++ function as .call _funcname(parameters)
Example:There are few things to notice here.Code: Select all
SWAP2 lastVal, reg1 SWAP4 reg1, reg1 .call _write_to_disk(reg1) ZERO lastN ZERO lastVal B savelastVN ; Branch
- The C/C++ function is write_to_disk. But we have added '_' prefix. This usual as the compiler adds '_' to functions in the symbol table
- Whenever we pass a parameter from ASM, we need to make sure the C/C++ function is ready accept the size of a register. For example: In a 32-bit system where registers are 32-bit, the C/C++ function prototype must be something like write_to_disk(int value)
NOTE 2 : If it is x86 assembly, the calling function is 'call' without the dot (.) prefix.