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: Terry Lambert <email@hidden>
- Date: Mon, 15 Sep 2008 15:25:01 -0700
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