Joined
·
6,071 Posts
It's been a while since I've had [adequate] time to work on my emulator. So now that I actually have some of that free time again, I need to get back to work on it. Now, I've generally got the basics of my binary translator going already, but the one thing that has me scratching my head is emulating the flags. This is mainly due to the fact that I was more focused on getting my code emitter to stop crashing!
When writing your code block, do you need to pre-determine how flags will be affected? Or is there a better way? Sorry, my brain is kinda fried atm. This is what I originally planed on doing, but it's probably not the best thing to do. Oh yeah, my core is an x86 -> x86 binary translator.
May or may not work. Is there a better way to do this? I still have much to learn about dynarec in general. Thanks.
When writing your code block, do you need to pre-determine how flags will be affected? Or is there a better way? Sorry, my brain is kinda fried atm. This is what I originally planed on doing, but it's probably not the best thing to do. Oh yeah, my core is an x86 -> x86 binary translator.
Code:
u32 pc_flags, xbox_flags;
__asm
{
// Save host flags
push eax
popfd pc_flags
// Set emulated flags
pushfd xbox_flags
// Execute code
call code_addr
// Save emulated flags
popfd xbox_flags
// Restore host flags
pushfd pc_flags
pop eax
}