On 09/29/2010 08:51 PM, Kevin O'Connor wrote:
On Wed, Sep 29, 2010 at 08:19:33AM -0700, H. Peter Anvin wrote:
Yeah... big real mode is rather expensive in terms of the 66 and 67 prefixes you end up littering the code with just to be in the mode you actually want. Better then to load a GDT, flip CR0.PE, and go to a 32-bit code segment anyway.
That brings up an interesting question. Do you know if instruction prefixes result in slower cpu execution? I know they bloat the code, but it's not been clear to me if there is a speed impact (besides a small cost to insn fetching). Real mode execution is documented to be slow, but it's unclear if using regular 32bit operations (via prefixes) would be even slower, the same, or a little faster.
BTW, I calculate that prefixes represent 12% of the seabios 16bit code size (4720 of 38920 bytes). I've found the code size with gcc (using prefixes) was smaller than the code size was with bcc - largely due to the optimizations and improved code structure that gcc enabled.
-Kevin
On older processors they do slow down the CPU, on modern CPUs they generally don't, except for icache footprint, of course.
In general real mode execution is no slower than the corresponding protected mode.
I worked for a while on a 16-bit gcc backend... I kind of stopped because of perceived lack of interest, and it wasn't fully usable yet, but perhaps Seabios would be enough of a reason. It seemed to produce code about 15% smaller than gcc with prefixes.
-hpa