VOGONS


Mov Ew,Sw Question

Topic actions

First post, by danoon

User metadata
Rank Member
Rank
Member

Normal core

CASE_D(0x8c)												/* Mov Ew,Sw */
{
GetRM;Bit16u val;Bitu which=(rm>>3)&7;
switch (which) {
case 0x00: /* MOV Ew,ES */
val=SegValue(es);break;
case 0x01: /* MOV Ew,CS */
val=SegValue(cs);break;
case 0x02: /* MOV Ew,SS */
val=SegValue(ss);break;
case 0x03: /* MOV Ew,DS */
val=SegValue(ds);break;
case 0x04: /* MOV Ew,FS */
val=SegValue(fs);break;
case 0x05: /* MOV Ew,GS */
val=SegValue(gs);break;
default:
LOG(LOG_CPU,LOG_ERROR)("CPU:8c:Illegal RM Byte");
goto illegal_opcode;
}
if (rm >= 0xc0 ) {GetEArd;*eard=val;}
else {GetEAa;SaveMw(eaa,val);}
break;
}

Should that GetEard be GetEarw?

Reply 1 of 6, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Yes, looks like it should read

{GetEArw;*earw=val;}

for the non-prefixed and 0x66 prefixed variant.

Reply 2 of 6, by danoon

User metadata
Rank Member
Rank
Member

Maybe a solution could be to remove CASE_D(0x8c) and replace CASE_W(0x8c) with CASE_B(0x8c)?

Reply 3 of 6, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I've checked sandpile and AMD docs, both define the instruction as register-dword but
memory-word only function (the first using zero-extension of the seg reg) so the current
implementation in dosbox matches this (if i'm not completely misreading the bochs sources
this is what they're doing as well).

Reply 4 of 6, by danoon

User metadata
Rank Member
Rank
Member

Thanks for checking that. I'll add a comment to the java cores that it is intentional so that I don't trip myself up again. 😀

https://github.com/danoon2/Boxedwine

Reply 5 of 6, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Well i can't claim the code is correct, but all hints at that even though it kicks orthogonality quite hard.

Reply 6 of 6, by peterferrie

User metadata
Rank Oldbie
Rank
Oldbie

It is correct. The register is zero-extended in 32-bit mode, even though a selector is only 16 bits.