User forums > Using Code::Blocks
x86 assembly problem
(1/1)
i386:
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:
--- Code: ---
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;
}
--- End code ---
In the file func.S, the related code is:
--- Code: --- .text
.global _func
_func:
enter 0, 0
mov ebx, esp
mov eax, fs : [ebx] ##### This is line 26
leave
ret
--- End code ---
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.
ollydbg:
Welcome, but I think it is not an issue related to C::B?
You should asked this kind of question in stackoverflow or some other maillist.
i386:
Thanks. It's solved.
Navigation
[0] Message Index
Go to full version