• Advertisement
Sign in to follow this  

AT&T asm + class members

This topic is 4415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! In Intel syntax I can access class member variables for ex. in the following way: // for sphere[0].pos[2]... fsub double ptr Sphere.pos+16[EBX]; How can I do this in AT&T syntax? thx, d0d

Share this post


Link to post
Share on other sites
Advertisement
It looks like you're trying to access array values rather than struct members. I suppose both of those actions are similar.

What is the offset of pos in sphere? For the sake of argument let's suppose that the offset is 24 and lets also assume the existence of an assembler token named _SpherePos that represents that value. The converted instruction would look something like this

fsubs _SpherePos+16(%ebx);


If you're interesting in learning more about at&t here are some links to documents regarding AT&T inline assembler in various compilers that use it.

Brennan's Guide to Inline Assembly (DJGPP)

Assembler with LCC-Win32

And here's an archive of a number of gcc manuals made into .chm files (Windows Compressed html help files)

htmlhelp/books

as-2.14.chm contains the manual for gas assembler.
gcc-3.3.2.chm contains the manual for gcc.
other files to note gccint-3.3.2.chm, cpp-3.3.2.chm, cppinternals-3.3.2.chm.

(You might want to look for newer versions of those files as I cut and pasted the names from an earlier post asking a similar question about AT&T asm).

Share this post


Link to post
Share on other sites
Hi!

Thanks for the links, I'm checking them now.

Actually the example I gave was a bit misleading...

class CSphere
{
public:
int a;
float foobar;
}

I would like to access a CSphere object's foobar member. This can be done from Intel syntax in an intuitive way.

Share this post


Link to post
Share on other sites
Intuitive because the assembler determines the offsets in a similar way that a C or C++ compiler would.

Accessing foobar boils down to determining the offset of that member in the class. I don't know where the vtbl fits in there, but it's there someplace. Determining a struct offset would be easier! [smile]

Two years ago I put together some notes for myself regarding addressing modes and AT&T syntax that you might find helpful: amodes.zip. I've learned a lot more about assembler since then but I haven't updated these notes, so if part of my explanation of the various addressing modes doesn't seem correct to you, it probably isn't. If you find that to be the case, please let me know. I am a lot more confident in the last section of those notes where I provide a few tips for converting Intel syntax to AT&T syntax. Hopefully you'll find those tips helpful.

Share this post


Link to post
Share on other sites
Great notes, thanks!

> Intuitive because the assembler determines the offsets
> in a similar way that a C or C++ compiler would.

But I'm interested in whether GCC can do the same or not, and if yes, how :)

Share this post


Link to post
Share on other sites
I believe there's a command line argument for newer versions of gcc that allows for using Intel syntax. If you're using Windows, open a command prompt to the directory containing gcc and pipe the help output to a text file for easier reference.

For example, on the computer I'm using right now I would open the command prompt to "C:\Dev-Cpp\bin>" and type "gcc -v --help > gcc_help.txt"

Then I would open gcc_help.txt in notepad or whatever and search for "asm" and related words. It appears the switch is "-masm=", but it's not clear what values are valid for that switch. This reference, AT&T Syntax versus Intel Syntax, suggests that ".intel_syntax" might work - but that reference appears specific to GAS rather than GCC.

Here's another reference that appears useful: GCC-Inline-Assembly-HOWTO.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement