I have this code in Assembly that I want to open a C program, passing a parameter and after the execution of this C program, a value is returned to my Assembly program.
More specifically, this:
- Open a C program passing a String as parameter.
- The C program will convert this String into a float and return it
- I'll catch this float and use it as I need in my assembly program.
[ASM] // Executing Assembly code
\-------------> // Run C Program passing a value as parameter
[C Program] // Do Stuff
/-------------> // Return value that I can catch back in my Assembly code
[ASM] // Goes back to executing Assembly code using value the
// value received by the C program.
Important info: I'm on Linux, and am not sure of what is my C binary. *.out maybe? Could use a few pointers on that too.
P.S: I'm aware of all the floating point instructions and the countless other options I have for doing that all in Assembly, but it's for my Computer Architecture and Organization class and that's how I need it to be.
Thanks everyone.
EDIT: Let me explain it a little better.
I have compiled this C code into a file called Convert and placed it into the same folder as my Assembly (.s) code:
//#includes
int main(int argc, char* argv[]){
float fVal;
sscanf(argv[1], "%f", &fVal);
return fVal;
}
Via Assembly, I want to execute Convert passing a string as "3.1415" as parameter. Convert will convert it to float and return.
Via Assembly, I'll then POP that from the stack and use the Float 3.1415.
All I have in mind is something like a System Call:
push parameter
push Executable's name
sys ! to wake the system to run my executable
pop eax ! pop the Float returned by Convert to EAX
Hope it's clearer now.
Again, thanks!
sscanfit will most likely not containexecvetoo. Thats the name of the function you are looking for, BTWsscanffrom my external C program which includes the Standard Library, but my Assembler, which implements itself the System Calls to only a few functions of the Std. Lib. doesn't have all the functions I need. I could implement them myself, though, and even tried, but against a bad formatted code with few comments which are in Dutch, I just can't win...