Re: GNU assembler freaks out at jumps and Intel syntax
Re: GNU assembler freaks out at jumps and Intel syntax
- Subject: Re: GNU assembler freaks out at jumps and Intel syntax
- From: LuigiG <email@hidden>
- Date: Mon, 15 Sep 2008 16:15:03 -0700 (PDT)
But that's using the AT&T syntax. That has always worked fine for me too, it's only when you switch to Intel syntax that you get problems.
If I chnage your example to use Intel syntax (even limited to that small bit of code), it doesn't work anymore:
This assembles (and links) correctly:
testl êx,êx
jnz L5
This will fail:
.intel_syntax noprefix
test eax,eax
jnz L5
.att_syntax
foo.s:28:suffix or operands invalid for `jnz'
So, is this a bug in gas? Or must I prepend/append something "L5" when using Intel syntax? (which would seem to contradict the "noprefix" option!)
Luigi
Note: I'm on an intel Mac and both -arch i386 and -arch x86_64 give the same result.
--- On Tue, 9/16/08, Terry Lambert <email@hidden> wrote:
From: Terry Lambert <email@hidden>
Subject: Re: GNU assembler freaks out at jumps and Intel syntax
To: email@hidden
Cc: email@hidden
Date: Tuesday, September 16, 2008, 12:25 AM
On Sep 14, 2008, at 9:04 AM, LuigiG wrote:
> Hi,
>
> What is the correct syntax for conditional jumps (j<cc>) in GNU as
> when using intel syntax?
>
> Specifically:
>
> # This dummy example code does not assemble:
> .intel_syntax noprefix
> L1:
> test eax,eax
> jnz L1
> ret
> .....
> %as test1.s
> %test1.s:6:suffix or operands invalid for `jnz'
>
>
> # This code (same but temp. switch to AT&T syntax) assembles
> correctly:
> .intel_syntax noprefix
> L1:
> test eax,eax
> .att_syntax
> jnz L1
> .intel_syntax noprefix
> ret
>
> % as test2.s
> % otool -Vt test2.o
> test2.o:
> (__TEXT,__text) section
> 00000000 testl êx,êx
> 00000002 jne 0x00000000
> 00000004 ret
>
> I'm using: Apple Inc version cctools-698.1~1, GNU assembler version
> 1.38
>
> What's up??
You are either not specifying -arch i386 and are compiling on a PPC,
or you failed to include the .text directive, or you are failing to
use cc rather than as to build the .o file from the .s file. Try this
with cc -arch i386 -S foo.c:
#include <stdio.h>
int
main(int ac, char *av)
{
if (ac == 2)
goto there;
printf("Here\n");
there:
printf("There\n");
}
Then hack the output .s it to change:
leal LC0-"L00000000001$pb"(ëx), êx
movl êx, (%esp)
call L_puts$stub
L2:
to:
leal LC0-"L00000000001$pb"(ëx), êx
movl êx, (%esp)
call L_puts$stub
testl êx, êx
jnz L5
L2:
And then do cc -arch i386 -o foo foo.s; works fine for me.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden