VOGONS


Pentium MMX emulation patch

Topic actions

Reply 20 of 24, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie

I think that's a bit of a mess at the moment. When X86_DYNFPU_DH_ENABLED is defined and the dyn_x86 core is active, it saves/restores the x87 state when it enters/exits the dynamic code (to the dyn_dh_fpu struct) but never actually copies everything back to the global FPU_rec struct.

So TL;DR: you need to manually copy them to/from the dyn_dh_fpu.state.st_reg array.

Reply 21 of 24, by kekko

User metadata
Rank Member
Rank
Member
jmarsh wrote on 2020-06-24, 16:15:

I think that's a bit of a mess at the moment. When X86_DYNFPU_DH_ENABLED is defined and the dyn_x86 core is active, it saves/restores the x87 state when it enters/exits the dynamic code (to the dyn_dh_fpu struct) but never actually copies everything back to the global FPU_rec struct.

So TL;DR: you need to manually copy them to/from the dyn_dh_fpu.state.st_reg array.

Hmm, it looks like that array saves/restores host fpu regs, not emulated machine ones.
I can't understand when I should save/restore mmx regs to fpu.regs[], and if anything else needs to be done. Any hint?

Reply 22 of 24, by kekko

User metadata
Rank Member
Rank
Member
jmarsh wrote on 2020-06-24, 16:15:

I think that's a bit of a mess at the moment. When X86_DYNFPU_DH_ENABLED is defined and the dyn_x86 core is active, it saves/restores the x87 state when it enters/exits the dynamic code (to the dyn_dh_fpu struct) but never actually copies everything back to the global FPU_rec struct.

So TL;DR: you need to manually copy them to/from the dyn_dh_fpu.state.st_reg array.

Ok I got an effect, reaching titles with the game in the first post, by just commenting out dyn_mmx_check define.
Apparently he is mixing host fpu status and emulated mmx status, by letting them share host regs.
The recompiler backs up host fpu status before running a block, in CPU_Core_Dyn_X86_Run > gen_dh_fpu_save
Then restores host fpu status at end of block, in CreateCacheblock > dyn_closeblock > dyn_fill_blocks
This breaks mmx status across different blocks.

you know the recompiler far better than me; do you have any suggestion on a possibly polite solution for this?