delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/11/16:40:26

Date: Mon, 12 May 1997 08:38:55 +1200
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: Re: Aligning Loops
To: Dave McNeill <dmcneill AT pne DOT co DOT uk>
Cc: djgpp AT delorie DOT com
Reply-to: billc AT blackmagic DOT tait DOT co DOT nz
Message-id: <33762E5F.6C2F@blackmagic.tait.co.nz>
Organization: Tait Electronics NZ
MIME-version: 1.0
References: <336f2c7b DOT 16228026 AT news DOT demon DOT co DOT uk>

Dave McNeill wrote:
> 
> I noticed something strange today while examining
> compiler output.  gcc had emitted '.align 2,0x90'
> to insert NOP's into the compiled code.  When I
> took a disassembly of the resulting .EXE, gas had
> assembled the above as 'lea esi,[esi]' (8dh, 36h).
> 
> Why?

It's a 2 byte nop.  gas does this in the text section to minimise the
number of nop instructions (one 2 byte nop is faster than 2 one byte
nops).  When browsing the gas source, I saw a table of these that went
all the way up to 16 bytes (I think).  I beleive each 'nop' is carefully
chosen to be both a nop and have the minimum clock cycles.

BTW 0x90 is realy xchg ax,ax (or al,al, not sure), there's a whole slew
of (obviously) undocumented nops.

Bill
-- 
Leave others their otherness.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019