tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] asmtest.S?


From: Rob Landley
Subject: Re: [Tinycc-devel] asmtest.S?
Date: Mon, 7 May 2007 13:10:09 -0400
User-agent: KMail/1.9.1

On Sunday 06 May 2007 11:32 pm, David A. Wheeler wrote:
> Rob Landley:
> > Does anybody know what asmtest.S is for?  I can't find a current user of 
it, 
> > and I suspect that A) it should be in the tests directory, B) it should be 
> > hooked up to Makefile somehow.
> 
> I think your intuition is on the money.  Sure looks like a testcase to me.
> 
> But when I ran asmtest.S through tcc, 'as', and gcc in the "obvious" way,
> they ALL produced DIFFERENT disassembled results (!!).  Both gcc and 'as'
> (gas) complain about a number of the operators; they may be guessing wrong,
> which would explain why they differ from tcc.  But what's mind-boggling is
> that the disassembled assembly from 'as' and gcc differ (!) - not just in
> the ELF header, but the actual disassembled code!  Maybe gcc sets some
> options to 'as' before it's called that accounts for the gcc/'as'
> difference.       
> 
> It'd be nice if the ASM test could compare the output generated from
> a "believed good" program when you hook it into the makefile.  I haven't had
> time to do more than notice that the outputs are different, but now you
> know...!   

Modern assemblers are a long way from the 1-1 translators of old.  The output 
differing doesn't worry me, as long as the result does what it's supposed to.

> --- David A. Wheeler
> 
> ==== Script to compare assembler outputs (Unix-like only) ====
> ./tcc -B. -I. -c -o asmtest.tcc.o asmtest.S
> as -o asmtest.as.o asmtest.S
> gcc -c -o asmtest.gcc.o asmtest.S  # Diff size output!
> for file in asmtest.tcc.o asmtest.as.o asmtest.gcc.o
> do
>  objdump -d $file > $file.objdump
> done
> md5sum *.objdump  # Different!
> 
> 
> 
> 
> === Note that 'as' produces different output than gcc ===
> -asmtest.as.o:     file format elf32-i386
> +asmtest.gcc.o:     file format elf32-i386
> 
>  Disassembly of section .text:
> 
> @@ -426,80 +426,80 @@
>   54d:  f4                      hlt
>   54e:  9b                      fwait
>   54f:  90                      nop
> - 550:  67 67 f0 f3 f3 f3 f2    repz repnz lock addr16 invd
> - 557:  f2 0f 08
> - 55a:  0f 09                   wbinvd
> ...
> + 550:  f0 f3 f3 f3 f2 f2 0f    repz repnz lock invd
> + 557:  08
> + 558:  0f 09                   wbinvd
> + 55a:  0f a2                   cpuid

The disassembler lost its marbles.  The only difference is two 0x67 bytes 
inserted above, the rest looks identical (modulo some liberties taken with 
the diff and possibly cutting the first early?)

Since I don't know what 0x6767 does, it could be padding that gcc cut out.

Rob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]