Simple AT&T ASM Prob

Programming, for all ages and all languages.
Post Reply
srg

Simple AT&T ASM Prob

Post by srg »

Hi

This is my first real attempt at any AT&T inline asm and this is driving me arround the bend:

asm ("movl %esp, %0": "=g" (temp) : : "memory");

I want to move a value from esp to a local variable called temp but I get this error:

operand number missing after %-letter

What am I doing wrong?

thanks
srg
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Simple AT&T ASM Prob

Post by Candy »

srg wrote: asm ("movl %esp, %0": "=g" (temp) : : "memory");
...
operand number missing after %-letter
asm ("movl %%esp, %0": "=g" (temp) : : "memory");

AT&T sucks.
srg

Re:Simple AT&T ASM Prob

Post by srg »

Candy wrote:
srg wrote: asm ("movl %esp, %0": "=g" (temp) : : "memory");
...
operand number missing after %-letter
asm ("movl %%esp, %0": "=g" (temp) : : "memory");

AT&T sucks.
Well I'm still concidering coding any assembly as seperate routines in NASM, I'm nice and familliar with that.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Simple AT&T ASM Prob

Post by Solar »

One, GNU as (the assembler used for inline ASM in gcc) can also to Intel syntax.

Two, AT&T doesn't suck any more than any other ASM dialect, just because a user used the wrong syntax. If I forget a '$' in my Perl script, that's just as wrong and doesn't say Perl sucks.

Three, personally I consider AT&T syntax much superior because I have previous experience on 6502 and 68k CPUs - I consider Intel syntax to be seriously broken. ;-)
Every good solution is obvious once you've found it.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Simple AT&T ASM Prob

Post by Candy »

Solar wrote: One, GNU as (the assembler used for inline ASM in gcc) can also to Intel syntax.
In a broken way, with still most of the same problems Intel-syntax people had with at&t syntax.
Two, AT&T doesn't suck any more than any other ASM dialect, just because a user used the wrong syntax. If I forget a '$' in my Perl script, that's just as wrong and doesn't say Perl sucks.
I wasn't referring to the user error but more to the unintuitive (yes, I know it's only past experience, don't flame me now) concept of using one percent-sign with registers, but if you use arguments you have to modify them all to use 2 percent signs.
Three, personally I consider AT&T syntax much superior because I have previous experience on 6502 and 68k CPUs - I consider Intel syntax to be seriously broken. ;-)
I can understand that, have done 68HC11 programming myself. Still, for x86es the intel syntax is lots better (imo). I still can't figure out how exactly to encode a sib operation in AT&T syntax, but in intel syntax its just [xxx] with on the place of XXX some addition of some operands you'd like. Lots more intuitive than a 8(ebx, eax, 4) something to me...
Post Reply