String Instructions 16 bits or 32 bits ??? 
Author Message
 String Instructions 16 bits or 32 bits ???

I noticed this strange effect on my old 486 cpu a few years ago.
On a 386+ cpu (32 bit) does the string instructions LODSx, MOVSx, STOSx
etc.. use 16 bits OR does it use 32 bits as the addresses in the EDI and ESI
registers ???

Try the following in either REAL or V86 mode:-

        MOV    ESI, 00010000h        ; more than 64 Kb right ?
        LODSB

The cpu hangs with a GPF, ok so far.... The CPU appears to use the full
32-bit values in the ESI and EDI registers. Now try the same thing during a
software or hardware INT routine.

e.g.
        MOV    ESI, 00010000h
        INT    0FFh                    ; INT FF has already been set up
before hand.
        ...
        .... etc....

my_int_ff_handler:
        push    si
        push    ds

        mov    ds,si
        mov    si,0                ; NOTE: we've only loaded the bottom 16
bits !!!
        lodsb                        ; so ESI contains xxxx0000 hex...
        pop    ds
        pop    si
        iret

Here is the surpise, the ESI register appears to only be 16-bit wide. I have
done tests to examine the ESI register and it wraps at 64K rather than the
full 32 bit value. The top 16-bits are unaffected... bizarre....

I've only tested this on an 486 dx2, so it might just be a bug..

from:
        TAD



Mon, 19 Mar 2001 03:00:00 GMT  
 String Instructions 16 bits or 32 bits ???

Quote:

> Try the following in either REAL or V86 mode:-

>         MOV    ESI, 00010000h        ; more than 64 Kb right ?
>         LODSB

> The cpu hangs with a GPF, ok so far.... The CPU appears to use the full
> 32-bit values in the ESI and EDI registers.

  Reexamine that test and look for other reasons why it might have
hung.  The CPU only uses the low 16 bits of si in that instruction
in those modes.

  If you had added an address size override, it would have used the
full 32 bits (and gotten a gpf).

Quote:
> Now try the same thing during a software or hardware INT routine.
. . .
> Here is the surpise, the ESI register appears to only be 16-bit wide
. . .
> I've only tested this on an 486 dx2, so it might just be a bug..

  It will be the same on a 386 or a Pentium.
--
http://www.erols.com/johnfine/
http://www.geocities.com/SiliconValley/Peaks/8600/


Mon, 19 Mar 2001 03:00:00 GMT  
 String Instructions 16 bits or 32 bits ???
Mind-control rays from black helicopters made "TAD"

Quote:
>Try the following in either REAL or V86 mode:-

>        MOV    ESI, 00010000h        ; more than 64 Kb right ?
>        LODSB

>The cpu hangs with a GPF, ok so far....

Not on my system, it doesn't. I used a de{*filter*} to single-step this
code, while in V86 mode (Win95 DOS box).

Quote:
>The CPU appears to use the full 32-bit values in the ESI and EDI registers.

Only (by default) in 32-bit pmode. In other modes it uses 16-bit SI.
If you do want to use ESI in 16-bit mode or SI in 32-bit mode, add a
prefix:

        a32             ; for NASM 0.93, use db 67h
        lodsb



Wed, 21 Mar 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. 16 bits versus 32 bits instructions

2. 16 bits versus 32 bits instructions

3. 16 bits vs 32 bits apps

4. 16 bits Version faster than 32 bits ?????

5. 32-bits / 32-bits

6. CW2.003 Btrive 6.15 from 16 to 32 bits

7. 16-32 bits API to retrieve PNP modem Brand on W95/98

8. 16 vs 32 bits Applications

9. 16/32 Bits apps speed.

10. Oracle accelerator and 16 bits vs 32 -- newby

11. 16-32 bits

12. calling 16-bit code from 32-bits

 

 
Powered by phpBB® Forum Software