Hi,
What I want to know are the following two things:
1) Under fastcall, how can I return multiple values to C++ using registers? (as under fastcall C++ can officially take only RAX I think. And I do not wish to use a struct or class).
In the following trial code I used std::pair just to make my point clearer.
#include <iostream>
using namespace std;
extern "C" std::pair<string, string> testCall(char* a, char* b, char**);
int main() {
char* somebuf =(char*) malloc(256);
std::pair<string, string>res = testCall( "Hello", "World", &somebuf );
cout << res.first <<rec.second<<endl;
cout<<somebuf <<endl;
return 0;
}
2) If I pass a third argument in my function to get some output value from the assembler, how to load that value/pointer in the assembly routine? (like the somebuf vars in my example ).
A very simple asm code I tried:
segment .text
global testCall
testCall:
pushfq
mov rax, rdx
mov rdx, rcx ; How to get the value of RDX in C++?
mov r8, rdx ; How to send back the R8 register/pointer to &somebuf?
popfq
ret
Appreciate your help.
Thanks.