Behaviour of reg32 with SMSW/SLDT/STR?

Emulation of old PCs, PC hardware, or PC peripherals.

Behaviour of reg32 with SMSW/SLDT/STR?

Postby superfury » 2019-2-25 @ 14:42

What is the resulting value of the register when using e.g. EAX with SMSW, SLDT and STR on a 80386/80486?

It seems "SMSW EAX" is used with some MS-DOS extenders, but that might not be working on a 80386?

What about STR and SLDT?

https://github.com/corkami/docs/blob/master/x86/x86.md
http://board.flatassembler.net/topic.php?t=6917
superfury
l33t
 
Posts: 3231
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: Behaviour of reg32 with SMSW/SLDT/STR?

Postby crazyc » 2019-2-25 @ 14:54

SMSW EAX stores all of CR0 into EAX. STR and SLDT do what you'd expect.
crazyc
Member
 
Posts: 143
Joined: 2013-2-02 @ 16:17

Re: Behaviour of reg32 with SMSW/SLDT/STR?

Postby superfury » 2019-2-25 @ 15:24

Hmmmm.... Bochs seems to agree on SMSW. But it does support 32-bit registers on STR and SLDT?

Code: Select all
if (i->modC0()) {
303     if (i->os32L()) {
304       BX_WRITE_32BIT_REGZ(i->dst(), val16);
305     }
306     else {
307       BX_WRITE_16BIT_REG(i->dst(), val16);
308     }
309   }
310   else {
311     bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
312     /* pointer, segment address pair */
313     write_virtual_word(i->seg(), eaddr, val16);
314   }


Is that invalid on a 80[3/4]86?
superfury
l33t
 
Posts: 3231
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: Behaviour of reg32 with SMSW/SLDT/STR?

Postby superfury » 2019-2-25 @ 19:13

IBMulator seems to verify said behaviour of SMSW, STR and SLDT as well?
superfury
l33t
 
Posts: 3231
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: Behaviour of reg32 with SMSW/SLDT/STR?

Postby crazyc » 2019-2-26 @ 13:42

It's cpu dependent. From the IA32 manual "Outside IA-32e mode, when the destination operand is a 32-bit register, the 16-bit segment selector is copied into the low-order 16 bits of the register. The high-order 16 bits of the register are cleared for the Pentium 4, Intel Xeon, and P6 family processors. They are undefined for Pentium, Intel486, and Intel386 processors. When the destination operand is a memory location, the segment selector is written to memory as a 16-bit quantity, regardless of the operand size." What "undefined" means you'd have to test on a real machine.
crazyc
Member
 
Posts: 143
Joined: 2013-2-02 @ 16:17

Re: Behaviour of reg32 with SMSW/SLDT/STR?

Postby hottobar » 2019-3-07 @ 18:59

crazyc wrote:What "undefined" means you'd have to test on a real machine.

On 486dx:
  • SMSW stores CR0
  • STR, SLDT, MOV SR: upper 16 bits are cleared
User avatar
hottobar
Newbie
 
Posts: 50
Joined: 2014-4-21 @ 17:00


Return to PC Emulation

Who is online

Users browsing this forum: No registered users and 1 guest