www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/10/10/03:16:00

From: cnc AT netcom19 DOT netcom DOT com (Christopher Christensen)
Date: Sun, 9 Oct 1994 20:18:45 PDT
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: 32/16bit?

>I think you are mixing different things here.
>
> There is nothing you have to 'change' on the processor to use 16 and 32 
>bit operations. The extra cycles you mention come if you have to switch 
>between protected mode and real mode - in DJGPP usually for calling MS-DOS 
>services

This is incorrect.  If you refer to the Intel processor manuals for the i486
and Pentium processors, you will find that when an instruction with 16-bit
operands exists in a 32-bit segment, it requires an OPERAND SIZE prefix.
The same is true for 32-bit instructions in a 16-bit segment.  This OPERAND
SIZE prefix is 1 byte long and takes 1 clock cycle to decode on both i486
and Pentium processors.  This means that for simple instructions like ADD
or MOV which normally take 1 clock cycle, using the wrong bitness will DOUBLE
the execution time of that instruction.  The upshot of all this is that for
time-critical code, you should use 32-bit instructions in 32-bit segments and
16-bit instructions in 16-bit segments.  Since djgpp executes all of its
code in 32-bit segments, this means you should avoid 16-bit operands like
the plague.  Avoid the "short" data type when reasonable.

Christopher


-- 
----------------------------------------------------------------------
:  Christopher  :  Huntington Beach California, USA                  :
:  Christensen  :  email:  cnc AT netcom DOT com                            :
----------------------------------------------------------------------

- Raw text -


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