27 April 2018, 19:38 | #1 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
68020 bitfield instructions in winuae
I am trying to find the 68020 bitfield instruction emulation in newcpu.cpp. Any hints where I might find those?
I am trying to backport a fix for guru in Virocop AGA in UAE4All2 Vita and I have a hunch it might be a problem with the bitfield instructions. |
27 April 2018, 20:49 | #2 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
|
All instruction emulation functions are located in CPU specific generated cpuemu_xx files + bitfield fetch/store helpers in newcpu_common.
|
27 April 2018, 21:57 | #3 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
Ah thanks for the hint. It looks much more complicated than I hoped.
|
28 April 2018, 09:17 | #4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
|
Yes, it isn't that simple but it shouldn't be too complex, first check bitfield instruction generation code in gencpu.cpp.
|
28 April 2018, 23:20 | #5 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
Since uae4all vita uses Famec I have to compare quite different sources.
Was there maybe an older version of WinUAE (from years ago) on github, where the bitfield operations where not yet auto-generated? It might make debugging uae4all vita easier if I could just update the ops one by one and see which one fixes the crash. Last edited by rsn8887; 28 April 2018 at 23:30. |
29 April 2018, 13:38 | #6 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
|
WinUAE never had non-generated 68k emulation. It was some really early UAE that did it differently, before "newcpu" existed.
I remember there was some bitfield fix ages ago, I think something in Dungeon Master II didn't work without the fix. |
01 May 2018, 22:40 | #7 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
Thanks! I found the fix you mentioned:
http://eab.abime.net/showpost.php?p=15755&postcount=23 I am looking at these bitfield instructions in the latest UAE4All code, where famec had been fixed by TomB a couple times already: https://github.com/rsn8887/uae4all2/...codes.h#L45673 I see a lot of commented out "& 7" parts, like: DREG((res >> 12) /*& 7*/) = dst; as well as a suspicious comment in BFCHG Code:
// BFCHG Dn - 68020+ OPCODE(0xEAC0) { u32 res; u32 dst; u32 mask, offset, width; FETCH_WORD(res) BF_REG_GET(res, dst, offset, width) mask = ((u32)0xFFFFFFFF << (32 - width)) >> offset; // BF_MASK(mask, offset, width) // BF_SHIFT_UP(mask, offset, width) DREG((Opcode /*>> 0*/) & 7) ^= mask; RET(12) } Code:
// BFCLR Dn - 68020+ OPCODE(0xECC0) { u32 adr, res; u32 dst; u32 mask, offset, width; FETCH_WORD(res) BF_REG_GET(res, dst, offset, width) mask = ((u32)0xFFFFFFFF << (32 - width)) >> offset; // BF_MASK(mask, offset, width) // BF_SHIFT_UP(mask, offset, width) DREG((Opcode /*>> 0*/) & 7) &= ~mask; RET(12) } Code:
// BFCLR (An) - 68020+ OPCODE(0xECD0) { u32 adr, res; u32 dst; u32 mask, width; s32 offset; u32 bf0, bf1; FETCH_WORD(res) adr = AREG((Opcode /*>> 0*/) & 7); BF_GET_PARM(res, offset, width) BF_MEM_GET(&adr, &dst, &offset, width, &bf0, &bf1); BF_SET_FLAGS(dst, width) BF_MASK(mask, offset, width) // dst &= ~mask; BF_MEM_PUT(adr, dst, 0/*mask*/, offset, width, bf0, bf1); RET(20) } |
02 May 2018, 02:31 | #8 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
Hmm it seems like the comments make sense if I assume someone improved the functions and commented out the old pieces instead of deleting them.
Now I am trying to compare the famec code in UAE4All2 here https://github.com/rsn8887/uae4all2/...codes.h#L45673 with Toni's code here https://github.com/tonioni/WinUAE/bl...ncpu.cpp#L5188 It would be good to know which exact instruction ViroCop AGA crashes at. I will try to use the WHDLoad expert switch to get more information. Last edited by rsn8887; 02 May 2018 at 02:38. |
02 May 2018, 05:07 | #9 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
I ran WHDLoad Expert and now I am not so sure it is the bitfield operations anymore since the pc stack just shows a bunch of regular btst operations and no bitfield op.
I am attaching a screenshot of the dump. Toni if you have a second maybe you can glance at this and see if it means anything to you? Does this reveal the bug in the emulation? Edit: I launched a few more times again and those times I got a line1111 error: Last edited by rsn8887; 02 May 2018 at 06:07. |
02 May 2018, 08:46 | #10 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
I guess the error happened before and caused some erroneous jump because the instruction sequence shown by WHDLoad makes no sense.
|
21 November 2018, 21:43 | #11 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
Update: I found a bitfield instruction that is executed just before the crash (Guru meditation) in Virocop AGA on UAE4All2 Vita/Switch:
https://github.com/rsn8887/uae4all2/...codes.h#L46347 it is this instruction: // BFFFO Dn - 68020+ OPCODE(0xEDC0) { u32 adr, res; u32 src, dst; u32 mask, offset, width; FETCH_WORD(res) BF_REG_GET(res, src, offset, width) BF_FFO(src, mask, offset, width) RET(18) } I think the implementation of this might be faulty? @ToniWilen: Can you see anything wrong with it? EDIT: I think I need to implement this patch: http://eab.abime.net/showpost.php?p=1051962&postcount=9 Last edited by rsn8887; 21 November 2018 at 22:11. |
21 November 2018, 23:34 | #12 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
That fixed it! No more crashes in ViroCop AGA. I suspect it is the only game ever that uses these bitfield instructions, though.
Last edited by rsn8887; 22 November 2018 at 00:59. |
22 November 2018, 00:16 | #13 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
@Toni Wilen: Does my fix make sense to you? If you have a second, it is here:
https://github.com/rsn8887/uae4all2/...15d816d1e7ee76 |
22 November 2018, 20:25 | #14 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
|
They look totally different compared to (win)uae implementation. I am not going to try to understand how it works in this port, sorry.
|
22 November 2018, 20:36 | #15 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,058
|
That’s fine thank you for taking a look. I went through them step by step to ensure they are working the same way as in WinUAE, so it should be ok.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A1000 68020 | Marchie | support.Hardware | 6 | 10 November 2017 12:08 |
Overclocking 68020? | Marchie | support.Hardware | 8 | 11 October 2016 13:33 |
68020 33 MHz | Leandro Jardim | support.WinUAE | 2 | 02 January 2012 19:21 |
Questions about 68020 CE | Maren | support.WinUAE | 11 | 09 December 2009 21:01 |
Apollo 1220 - instructions and 68020 to 68030 upgrade | fc.studio | support.Hardware | 11 | 10 January 2008 20:30 |
|
|