English Amiga Board Amiga Lore


Go Back   English Amiga Board > Support > support.WinUAE

 
 
Thread Tools
Old 21 November 2015, 11:59   #1
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
Bitfields BFFFO

Hi tony,

i think i found a diff between UAE and real 030 using BFFFO

here some isolated small code (i use devpac/monam) :

Code:
    MACHINE MC68030

Start:
    clr.l   d4
    move.l  #$1badcafe,d0
    move.l  #$20,d1
    move.l  #$20,d2
    bfffo   d0{d2:d1},d3 ; uae => 0000 0003 ; 030 => 0000 0023
    move.w  ccr,d4       ; uae => 0000 0000 ; 030 => 0000 0000
    stop    #-1
On UAE :
D3 = 0000 0003
D4 = 0000 0000

On my A1200/030 :
D3 = 0000 0023
D4 = 0000 0000

Last edited by flype; 21 November 2015 at 13:54.
flype is offline  
AdSense AdSense  
Old 21 November 2015, 13:54   #2
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
other test :

here all BFFFO results (D4) are not the ones i can see on my 1200 (D3).

Code:
    MACHINE MC68030

Start:
    lea     values,a0
Loop:
    move.l  (a0)+,d0
    beq     Exit
    move.l  (a0)+,d1
    move.l  (a0)+,d2
    move.l  (a0)+,d3
    bfffo   d0{d1:d2},d4
    bra     Loop
Exit:
    stop    #-1

values:
    ;              d0, d1, d2,   d3
    dc.l    $1badcafe,$ff,$ff,$0103 ; uae : d4=$0023
    dc.l    $1badcafe,$7f,$7f,$0083 ; uae : d4=$0023
    dc.l    $1badcafe,$20,$20,$0023 ; uae : d4=$0003
    dc.l    $1badcafe,$20,$03,$0023 ; uae : d4=$0003
    dc.l    $1badcafe,$20,$02,$0022 ; uae : d4=$0002
    dc.l    $1badcafe,$20,$01,$0021 ; uae : d4=$0001
    dc.l    0
flype is offline  
Old 21 November 2015, 13:59   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,561
Confirmed.

Interesting unexpected behavior, low 5 bits are used for offset when EA is register but when calculating result, all 32-bits are used.

(For example D0 = 0, D2 = 7FFFFFE0: D3 = 80000000)
Toni Wilen is offline  
Old 21 November 2015, 14:29   #4
amilo3438
Amiga 500 User
 
Join Date: Jun 2013
Location: EU
Posts: 1,114
whether it happens in jit mode also!?

Edit:
I wonder if somewhere there is already a better jit 680x0 emulation of existing and whether it could be used?

Last edited by amilo3438; 21 November 2015 at 14:38.
amilo3438 is offline  
Old 21 November 2015, 14:31   #5
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,561
No difference. JIT does not translate bitfield instructions, no one has bothered to implement them. They are very rare anyway.
Toni Wilen is offline  
Old 21 November 2015, 14:37   #6
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
Quote:
Originally Posted by Toni Wilen View Post
Confirmed.

Interesting unexpected behavior, low 5 bits are used for offset when EA is register but when calculating result, all 32-bits are used.

(For example D0 = 0, D2 = 7FFFFFE0: D3 = 80000000)
Yep, other samples :

Code:
    ;              d0,       d1,       d2,       d3
    dc.l    $ffffff00,$ffffff00,$7fffffe0,$ffffff00 ; uae : d4=$00000000
    dc.l    $00000000,$ffffffff,$7fffffe0,$0000001f ; uae : d4=$0000003f
    dc.l    $00000000,$00000000,$7fffffe0,$00000020 ; uae : d4=$00000020 (ok)
    dc.l    $00000000,$00000020,$7fffffe0,$00000040 ; uae : d4=$00000020
    dc.l    $1badcafe,$000000ff,$000000ff,$00000103 ; uae : d4=$00000023
    dc.l    $1badcafe,$0000007f,$0000007f,$00000083 ; uae : d4=$00000023
    dc.l    $1badcafe,$00000020,$00000020,$00000023 ; uae : d4=$00000003
    dc.l    $1badcafe,$00000020,$00000003,$00000023 ; uae : d4=$00000003
    dc.l    $1badcafe,$00000020,$00000002,$00000022 ; uae : d4=$00000002
    dc.l    $1badcafe,$00000020,$00000001,$00000021 ; uae : d4=$00000001

Last edited by flype; 21 November 2015 at 14:44.
flype is offline  
Old 21 November 2015, 15:29   #7
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,561
http://www.winuae.net/files/b/winuae.7z should fix it.
Toni Wilen is offline  
Old 21 November 2015, 15:58   #8
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
Great, thank you tony for fast reply (as always),
i need now to wait for fsuae release as i use only linux atm.
flype is offline  
Old 21 November 2015, 16:02   #9
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,561
Here is patch then

Code:
diff --git a/gencpu.cpp b/gencpu.cpp
index e8a2aa6..e52660e 100644
--- a/gencpu.cpp
+++ b/gencpu.cpp
@@ -5065,6 +5068,8 @@ bccl_not68020:
 			printf ("\tuae_u32 bdata[2];\n");
 			printf ("\tuae_s32 offset = extra & 0x800 ? m68k_dreg(regs, (extra >> 6) & 7) : (extra >> 6) & 0x1f;\n");
 			printf ("\tint width = (((extra & 0x20 ? m68k_dreg(regs, extra & 7) : extra) -1) & 0x1f) +1;\n");
+			if (curi->mnemo == i_BFFFO)
+				printf("\tuae_u32 offset2 = offset;\n");
 			if (curi->dmode == Dreg) {
 				printf ("\tuae_u32 tmp = m68k_dreg(regs, dstreg);\n");
 				printf ("\toffset &= 0x1f;\n");
@@ -5096,8 +5101,8 @@ bccl_not68020:
 				break;
 			case i_BFFFO:
 				printf ("\t{ uae_u32 mask = 1 << (width - 1);\n");
-				printf ("\twhile (mask) { if (tmp & mask) break; mask >>= 1; offset++; }}\n");
-				printf ("\tm68k_dreg (regs, (extra >> 12) & 7) = offset;\n");
+				printf ("\twhile (mask) { if (tmp & mask) break; mask >>= 1; offset2++; }}\n");
+				printf ("\tm68k_dreg (regs, (extra >> 12) & 7) = offset2;\n");
 				break;
 			case i_BFSET:
 				printf ("\ttmp = 0xffffffffu >> (32 - width);\n");
Toni Wilen is offline  
Old 21 November 2015, 16:07   #10
amilo3438
Amiga 500 User
 
Join Date: Jun 2013
Location: EU
Posts: 1,114
Quote:
Originally Posted by flype View Post
i need now to wait for fsuae release as i use only linux atm.
No need to Wait, you can use WINE, right? (According to some users it works fine.)

http://www.pjhutchison.org/uae_wine.html

Last edited by amilo3438; 21 November 2015 at 16:18.
amilo3438 is offline  
Old 21 November 2015, 16:09   #11
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
well maybe, i had problem with wine + winuae some times ago.
i should retry.
flype is offline  
Old 21 November 2015, 16:41   #12
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
Quote:
Originally Posted by Toni Wilen View Post
using the testcase here, it reports no more error

Code:
    MACHINE MC68030

Start:
    clr.l   d5               ; error counter
    lea     values,a0        ; load values
    move.l  (a0)+,d7         ; number of rows
Loop:
    move.l  (a0)+,d0         ; load d0
    move.l  (a0)+,d1         ; load d1
    move.l  (a0)+,d2         ; load d2
    move.l  (a0)+,d3         ; load d3
    bfffo   d0{d1:d2},d4     ; bitfield operation
    sub.l   d3,d4            ; check result
    beq     Next1            ; d4 = 0 ?
    addi.l  #1,d5            ; else, increment error counter
Next1:
    dbf     d7,Loop          ; continue
Exit:
    stop    #-1              ; stop

values:
    dc.l    9
    ;              d0,       d1,       d2,       d3
    dc.l    $ffffff00,$ffffff00,$7fffffe0,$ffffff00 ; 
    dc.l    $00000000,$ffffffff,$7fffffe0,$0000001f ; 
    dc.l    $00000000,$00000000,$7fffffe0,$00000020 ; 
    dc.l    $00000000,$00000020,$7fffffe0,$00000040 ; 
    dc.l    $1badcafe,$000000ff,$000000ff,$00000103 ; 
    dc.l    $1badcafe,$0000007f,$0000007f,$00000083 ; 
    dc.l    $1badcafe,$00000020,$00000020,$00000023 ; 
    dc.l    $1badcafe,$00000020,$00000003,$00000023 ; 
    dc.l    $1badcafe,$00000020,$00000002,$00000022 ; 
    dc.l    $1badcafe,$00000020,$00000001,$00000021 ;
EDIT: also ok with another bigger testcase.
flype is offline  
Old 21 November 2015, 16:55   #13
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,372
Quote:
Originally Posted by Toni Wilen View Post
No difference. JIT does not translate bitfield instructions, no one has bothered to implement them. They are very rare anyway.
Beware, as they are not really very rare ; just uncommon. DM2 for example is just full of them. I found many in HOMM2 too. My code uses them quite a lot as well.

They are real programming gems when knowing how to use them.

But they are quite complicated to implement, for sure.
meynaf is offline  
Old 21 November 2015, 17:03   #14
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,561
So that makes two programs (I only knew DM2 previously). Which in my opinion makes it extremely rare
Toni Wilen is offline  
Old 21 November 2015, 17:06   #15
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,372
Other programs of mine do (like my picture viewer).
Lots of Mac programs using the same compiler as HOMM2 used, also do.

Extremely rare is something like CHK2
meynaf is offline  
Old 21 November 2015, 17:12   #16
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
Just checked also the CCR results.

All good here, same on real 030 and WinUAE with the latest fix.

Code:
    MACHINE MC68030

Start:
    clr.l   d5               ; bitfield result
    clr.l   d6               ; bitfield ccr
    lea     values,a0        ; load rows
    move.l  (a0)+,d7         ; load number of rows
Loop:
    move.l  (a0)+,d0         ; load <ea>
    move.l  (a0)+,d1         ; load offset
    move.l  (a0)+,d2         ; load width
    move.l  (a0)+,d3         ; load precalc result
    move.l  (a0)+,d4         ; load precalc ccr
    bfffo   d0{d1:d2},d5     ; store bitfield result
    move.w  ccr,d6           ; store bitfield ccr
    sub.l   d3,d5            ; check bitfield result
    sub.l   d4,d6            ; check bitfield ccr
    dbf     d7,Loop          ; continue
Exit:
    stop    #-1              ; stop

values:
    dc.l    9
    ;              d0,       d1,       d2,       d3,       d4
    dc.l    $ffffff00,$ffffff00,$7fffffe0,$ffffff00,$00000008
    dc.l    $00000000,$ffffffff,$7fffffe0,$0000001f,$00000004
    dc.l    $00000000,$00000000,$7fffffe0,$00000020,$00000004
    dc.l    $00000000,$00000020,$7fffffe0,$00000040,$00000004
    dc.l    $1badcafe,$000000ff,$000000ff,$00000103,$00000000
    dc.l    $1badcafe,$0000007f,$0000007f,$00000083,$00000000
    dc.l    $1badcafe,$00000020,$00000020,$00000023,$00000000
    dc.l    $1badcafe,$00000020,$00000003,$00000023,$00000004
    dc.l    $1badcafe,$00000020,$00000002,$00000022,$00000004
    dc.l    $1badcafe,$00000020,$00000001,$00000021,$00000004
flype is offline  
Old 21 November 2015, 18:34   #17
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
One word to say that i found this bug while writing cross-testcases for the Vampire/Apollo and UAE and real 680x0. We spend huge amount of time to ensure that Apollo is 100% 68k compatible and we are happy to share this effort to UAE or others if something wrong is detected. And, last word, thanks Tony for UAE, that is of great help in doing this task.

Last edited by flype; 21 November 2015 at 19:09.
flype is offline  
Old 21 November 2015, 18:59   #18
Galahad/FLT
Going nowhere

Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 44
Posts: 6,505
Quote:
Originally Posted by Toni Wilen View Post
So that makes two programs (I only knew DM2 previously). Which in my opinion makes it extremely rare
Pretty sure Speris Legacy uses it as well, used for making save games as small as possible to fit in Cd32 NVram.
Galahad/FLT is offline  
Old 21 November 2015, 19:05   #19
flype
Registered User

flype's Avatar
 
Join Date: Dec 2014
Location: France
Posts: 66
Please, what is DM2 ? DiskMaster 2, Dungeon Master 2, what else ?
flype is offline  
Old 21 November 2015, 20:19   #20
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,372
Quote:
Originally Posted by flype View Post
Please, what is DM2 ? DiskMaster 2, Dungeon Master 2, what else ?
Dungeon Master 2.
meynaf is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 07:50.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.21292 seconds with 10 queries