I am using windows version code blocks 12.11, with integrated 32bit mingw gcc 4.7.1 on Windows 8.1.
In the file main.c, the related code is:
int func(void);
int main(void)
{
unsigned int reg = 0;
__asm volatile
(
"mov ebx, esp\n\t"
"mov eax, fs : [ebx]\n\t"
"mov %0, eax"
: "=m"(reg)
);
reg = func();
return 0;
}
In the file func.S, the related code is:
.text
.global _func
_func:
enter 0, 0
mov ebx, esp
mov eax, fs : [ebx] ##### This is line 26
leave
ret
The full compile log is:
-------------- Build: Debug in win (compiler: GNU GCC Compiler)---------------
mingw32-gcc.exe -Wall -g -m80387 -std=c99 -masm=intel -Wa,-msyntax=intel,-mnaked-reg -c D:\CB\win\main.c -o obj\Debug\main.o
mingw32-g++.exe -Wall -g -m80387 -std=c99 -masm=intel -Wa,-msyntax=intel,-mnaked-reg -c D:\CB\win\func.S -o obj\Debug\func.o
D:\CB\win\func.S: Assembler messages:
D:\CB\win\func.S:26: Error: junk `:[ebx]' after expression
As I used some x87 FPU instructions and 'long double' data type, so I add '-m80387 -std=c99' option.
I like 'intel assembly format', so I add '-masm=intel -Wa,-msyntax=intel,-mnaked-reg' option.
The instruction "mov eax, fs : [ebx]" is in both files, but the main.c compile ok and the other fail.