|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
using assembly with g++
how do enter an assembly block? this is what im used to doing:
Code:
int main(int argc, char *argv[])
{
char a = 'a';
_asm
{
movl a,EAX;
and 0x01000001,EAX;
mov EAX,a;
}
printf("%x\n",a);
return 1;
}
|
|
#2
|
||||
|
||||
|
|
|
#3
|
||||
|
||||
|
It appears to me that it may vary between implementations of g++ what the syntax will be and whether inline assembly is even supported.
At http://cs.wwc.edu/~aabyan/Unix/Assembly.html I found instructions for inline assembly with g++, but it seems more DJGPP-oriented. Their code would not compile with my MinGW gcc nor g++; it would not even recognize the asm keyword. I also could find no reference to assembly in the LibC help file. On my Redhat7 box, my version 2.96 gcc did recognize asm, but I had some compile errors. So you might have to do a bit of testing and searching for your particular g++. The key appears to be that you shouldn't give up too quickly if you run into problems. |
|
#4
|
||||
|
||||
|
thanks scorpions, that answered my question. also made me realize assembly is a lot different than im used to, (not to mention the pain of writing each line like this: asm("movl a,%eax"); )
Last edited by infamous41md : May 6th, 2003 at 11:18 AM. |
|
#5
|
||||
|
||||
|
Quote:
You should be able to write multiple lines of assembly code in a single asm statement; eg: Code:
asm("incl x
movl x, %eax
imull y
movl %eax,x
");
See whether your compiler requires a different syntax for this. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > using assembly with g++ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|