LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   problem in C++ (https://www.linuxquestions.org/questions/programming-9/problem-in-c-127278/)

usr 12-19-2003 10:55 AM

problem in C++
 
I tried to include some assembly code into C++ but I didn't worked.
In Windows all is just fine but with this code in test.cpp:

#include <iostream>

using namespace std;

int main()
{
char *a="this is a message";
int len=strlen(a);
_asm{
//some assembly code
}
return 0;
}

when "g++ -o test test.cpp" I receive an error telling me he doesn't know what "_asm" is.
Could someone tell me how could I correct this?

Thanks!

LogicG8 12-19-2003 12:08 PM

This link will help you out a lot.
http://cs.wwc.edu/~aabyan/Unix/Assembly.html

magicvash 12-20-2003 12:11 AM

If I'm not mistaken, _asm is a VC++ macro so g++ has no idea what you're talking about. To do this, just put the asm code in a .asm file, use nasm to assemble the code to a .o file and then use g++ -c to compile your c++ code and then use g++ -o outfile obj1.o obj2.o asmbleycode.o cpluspluscode.o main.o (etc...whatever, howevery many files you have) to make the final executable binary


All times are GMT -5. The time now is 03:23 PM.