Date: Mon, 12 May 1997 08:38:55 +1200 From: Bill Currie Subject: Re: Aligning Loops To: Dave McNeill 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 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit References: <336f2c7b DOT 16228026 AT news DOT demon DOT co DOT uk> Precedence: bulk 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.