Hi,
I am working on a project where I have to generate and execute nasm code on-the-fly. I generate the code in a file program.asm and then execute it.This output is to stdout which i redirect to an output file which i read back to compare results:
system("nasm -f elf program.asm > output");
The problem is I have to do this process (generate code and execute) a lot of times each time i run my program which slows the execution time due to so much file I/O.
Is there some shell trick by which I can generate my code in a string buffer (instead of the file program.asm) and pass it as input to nasm.
Similarly, can I capture the output of nasm into another string buffer without writing it to a file.
Same applies for compiling c programs using gcc. Can my c program be present in a string which i then compile using gcc by redirecting its input from a file to the string. Likewise, can i redirect the output of my c program to a string instead of stdout or any other file before.