Article 5DPSE inline assembly

inline assembly

by
vmelkon
from LinuxQuestions.org on (#5DPSE)
Hello,
I would like to convert a project (C/C++) to Linux.
x86 and I will change to x64.
The project uses inline assembly in certain places.
Are there any examples? It is easier for me to learn via examples.
I know that I have to use __asm__ ("string goes here")
I know that I have to use AT&T syntax.

Example:
It says that my function does not return a value
Code:int GoGoMMX()
{
__asm__
(
"mov $1, %eax;"
"cpuid;"
"test $0x00800000, %edx;"
"mov $0, %eax;"
"jz NotFound;"
"mov $1, %eax;"
"NotFound:"
"ret;"
);
//return returnVal;
}
This one gives
Warning: no instruction mnemonic suffix given and no register operands; using default for `mov'
Code:int GoGoMMX()
{
int returnVal;

returnVal=0;
__asm__
(
"mov $1, %eax;"
"cpuid;"
"test $0x00800000, %edx;"
"mov $0, %eax;"
"jz NotFound;"
"mov $1, returnVal;"
"NotFound:"
);

return returnVal;
}
}~~~~vmelkonlatest?d=yIl2AUoC8zA latest?i=IcnnWnMk0Cw:2t9AWJR7QHc:F7zBnMy latest?i=IcnnWnMk0Cw:2t9AWJR7QHc:V_sGLiP latest?d=qj6IDK7rITs latest?i=IcnnWnMk0Cw:2t9AWJR7QHc:gIN9vFwIcnnWnMk0Cw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments