Re: GNU assembler freaks out at jumps and Intel syntax
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Message-ID; b=eY8Soi5bLEzqXxMhumYy3XlYwNenbrgdj9BOOyGJWpY5gPWObNgNVd4bI9cJkapdnm22+fjTkxnVYFWO409yw+R3e3ZNb4lZafcS5EJYQ1lRsrqYV3ScH0oEVXvG1NyVLvEo0paQfb74fKIlohl0O5BeJsxhmdqSvrr6AtCg8+g=; 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 %eax,%eax 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 <tlambert@apple.com> wrote: From: Terry Lambert <tlambert@apple.com> Subject: Re: GNU assembler freaks out at jumps and Intel syntax To: news4e71@yahoo.com Cc: darwin-dev@lists.apple.com 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 %eax,%eax 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"(%ebx), %eax movl %eax, (%esp) call L_puts$stub L2: to: leal LC0-"L00000000001$pb"(%ebx), %eax movl %eax, (%esp) call L_puts$stub testl %eax, %eax 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
LuigiG