Dear Konstantin,
     Thank you giving me this important clue, I will have a read about Intel's
manual.
Regards,
Collins







Konstantin Zhidkov <[EMAIL PROTECTED]> on 2002-02-28 20:22:32
                                                              
                                                              
                                                              
  To:          Collins Chen/ALI_ZSZ/ACER@ACER                 
                                                              
  cc:          [EMAIL PROTECTED]                             
                                                              
                                                              
                                                              
  Subject      Re: Why CPU don't execute 16-bit code          
  :                                                           
                                                              







--- Collins Chen <[EMAIL PROTECTED]> wrote:

>      BTW, if CPU can execute "e8 01 00" correctly in
> protected mode?

Almost any 16-bit code can run correctly in protected mode if
both CS ans SP refer to GDT entries with D/B flag clear. But it
will run only until the first far jump. In V86 mode CPU can do
far jumps and other segment registers modifications correctly.

>
> my code:
>
>      movl %cr0, %eax          /*exit protected mode*/
>      andb $0xfe, %al
>      movl %eax, %cr0

After executing the above instruction, current properties of
segment registers (limit, stack/address widht, etc.) will be
kept by CPU, even in real mode. Before loading cr0 segment
registers should refer to GDT entries with 64K limit, 16-bit
stack/address width and all remaining attributes set to real
mode defaults. This is explained in IA-32 Intel Architecture
Software Developer's Manual Volume 3 : System Programming Guide
(http://developer.intel.com/design/pro/manuals/)
9.9.2. Switching Back to Real-Address Mode

Konstantin


__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com



Reply via email to