I have a function _writeHexASCII in assembly language that needs to be called
its takes two parameters (*int, unsigned long int)
How do I declare it in C so I can use it?
This is a discussion on Calling an Assembly Function within the C Programming forums, part of the General Programming Boards category; I have a function _writeHexASCII in assembly language that needs to be called its takes two parameters (*int, unsigned long ...
I have a function _writeHexASCII in assembly language that needs to be called
its takes two parameters (*int, unsigned long int)
How do I declare it in C so I can use it?
Take heed to note what the function returns and who cleans the stack (the function or the caller?).Code:extern return_type calling_convention writeHexASCII(int* p, unsigned long int n);
It may be tricky.
Then again, the assembly needs to be declared so the linker can find it. I can't help on that point.
Last edited by Elysia; 12-07-2007 at 01:51 AM.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
Link it.Code:extern void writeHexASCII(int *, unsigned long int);
Don't forget calling convention and return type (or does C have calling convention?).
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
All languages have a calling convention. The question is, of course, if the assembler being called is following the standard C calling convention in that particular machine. If not, the next question is to figure out if the calling convention expected by the assembler can be achieved from the particular compiler.
The calling convention determines:
1. Who cleans up the stack - caller or callee.
2. How parameters are passed, in registers (if so, how many registers and in which order) or on the stack. Also in which order the arguments are passed on the stack.
3. Which registers the function can use directly, and which registers must be preserved by the callee.
4. How the return value is returned to the caller, if there is a return value.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.