English Amiga Board


Go Back   English Amiga Board > Support > support.WinUAE

 
 
Thread Tools
Old 27 April 2018, 20:38   #1
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
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.
rsn8887 is offline  
Old 27 April 2018, 21:49   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,120
All instruction emulation functions are located in CPU specific generated cpuemu_xx files + bitfield fetch/store helpers in newcpu_common.
Toni Wilen is online now  
Old 27 April 2018, 22:57   #3
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
Ah thanks for the hint. It looks much more complicated than I hoped.
rsn8887 is offline  
Old 28 April 2018, 10:17   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,120
Yes, it isn't that simple but it shouldn't be too complex, first check bitfield instruction generation code in gencpu.cpp.
Toni Wilen is online now  
Old 29 April 2018, 00:20   #5
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
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; 29 April 2018 at 00:30.
rsn8887 is offline  
Old 29 April 2018, 14:38   #6
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,120
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.
Toni Wilen is online now  
Old 01 May 2018, 23:40   #7
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
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)
}
in BFCLR:
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)
}
and an &=~ repeatedly in BFCLR:
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)
}
Does any of this this look faulty to you?
rsn8887 is offline  
Old 02 May 2018, 03:31   #8
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
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 03:38.
rsn8887 is offline  
Old 02 May 2018, 06:07   #9
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
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:
Attached Thumbnails
Click image for larger version

Name:	E83A201B-E10E-4CBB-8EC3-35C429D78FE7.jpg
Views:	61
Size:	483.5 KB
ID:	58042   Click image for larger version

Name:	96FBC4C8-0D5D-46FF-B5F6-8787EC32F5FF.jpg
Views:	63
Size:	511.4 KB
ID:	58043  

Last edited by rsn8887; 02 May 2018 at 07:07.
rsn8887 is offline  
Old 02 May 2018, 09:46   #10
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
I guess the error happened before and caused some erroneous jump because the instruction sequence shown by WHDLoad makes no sense.
rsn8887 is offline  
Old 21 November 2018, 22:43   #11
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
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 23:11.
rsn8887 is offline  
Old 22 November 2018, 00:34   #12
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
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 01:59.
rsn8887 is offline  
Old 22 November 2018, 01:16   #13
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
@Toni Wilen: Does my fix make sense to you? If you have a second, it is here:
https://github.com/rsn8887/uae4all2/...15d816d1e7ee76
rsn8887 is offline  
Old 22 November 2018, 21:25   #14
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,120
They look totally different compared to (win)uae implementation. I am not going to try to understand how it works in this port, sorry.
Toni Wilen is online now  
Old 22 November 2018, 21:36   #15
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 814
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.
rsn8887 is offline  
 


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 13:08
Overclocking 68020? Marchie support.Hardware 8 11 October 2016 14:33
68020 33 MHz Leandro Jardim support.WinUAE 2 02 January 2012 20:21
Questions about 68020 CE Maren support.WinUAE 11 09 December 2009 22:01
Apollo 1220 - instructions and 68020 to 68030 upgrade fc.studio support.Hardware 11 10 January 2008 21:30

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:08.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.08037 seconds with 14 queries