Re: [Dev-C++] Offset problems in assembly
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel K. O. <dan...@ya...> - 2003-10-25 01:53:53
|
First: GCC uses AT&T syntax by default, but it accepts Intel as well.
You can set which syntax you want to use by default, with the "-masm=x"
compiler option, where "x" can be:
"att" -> for AT&T syntax
"intel" -> for Intel syntax (d'oh....)
So, with -masm=intel you can write:
---
char hello[] = "Hello";
__asm(
"mov ebx, _hello \n"
"more intel asm here... \n"
);
---
And with -masm=att (the default) you can do:
---
char hello[] = "Hello";
__asm(
"mov $_hello, %ebx \n"
"more at&t asm here... \n"
);
---
If you want to mix ASM code, you can use ".intel_syntax" and
".att_syntax" to change the syntax for the next lines. Just don't
forget to change it back to the default syntax:
Option -> -masm=att
---
char hello[] = "Hello";
__asm(
".intel_syntax \n"
"mov ebx, _hello \n"
"more intel asm here... \n"
".att_syntax \n" // back to default syntax
);
---
Also, check:
http://www.codeproject.com/useritems/gccasm.asp
And also the Dev-Cpp's FAQ.
And please, learn how to use Google, I found all this in the first
results page. ;)
Daniel K. O.
Bjorn Terelius wrote:
> I'm using visual studio for this project, so it may be the wrong place
> for the question.
> Anyway, when I try compile code like:
>
>
> char hello[] = "Hello";
> __asm
> {
> mov ebx, offset hello
> ...
> }
>
> the compiler fail and respond "error C2415: improper operand type"
> This only occur when I'm trying to use offset
>
> Does anyone recognize this?
> I havn't found any helpful information on MSDN or by searching with
> Google
>
> Thanks
> Bjorn Terelius
|