English Amiga Board


Go Back   English Amiga Board > Support > support.WinUAE

 
 
Thread Tools
Old 18 July 2017, 09:47   #1
jarp
Registered User

 
Join Date: Apr 2016
Location: Helsinki / Finland
Posts: 175
F-line exception bug?

Hi Toni!

I think I've found a bug from the latest WinUAE (3.5.0) related to F-line exceptions. This happens on 040 and 060 CPU settings, more compatible enabled, JIT disabled and FPU disabled. Bug can be easily reproduced:

Code:
	fmove.l	fp0,d0
WinUAE seems to actually execute this command like a FPU would be present. Instead, this should generate a f-line exception. Other way around WinUAE behaves as expected:

Code:
	fmove.l	d0,fp0
This will generate a f-line exception as expected. This bug seems not to concern all FPU commands, in fact this fmove from fpn to dn is so far only example I've found - but of course is a show stopper if you want to rely on f-line exceptions.

That being said with, using 020/030 CPU setting everything works smoothly, so I've just developed my stuff using 030 CPU setting

Thanks!

-Jari
jarp is offline  
Old 19 July 2017, 14:52   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 44
Posts: 23,244
Should be fixed now but it may not be perfect yet (non-existing test cases and stuff..)

Note that 68020/030 without 6888x is not same as 68040+ without FPU. 68040/060 F-line stack frame is different if cause was FPU instruction. (Includes extra data)
Toni Wilen is offline  
Old 21 July 2017, 19:25   #3
jarp
Registered User

 
Join Date: Apr 2016
Location: Helsinki / Finland
Posts: 175
Thank you Toni! I applied the patch to 3.5.0 code base (was unable to compile head version...) and this particular problem is now fixed.

Seems that there are further bugs (my application crashes with 040 CPU setting, no crash with 030 CPU setting or real 040 hardware). It or they are harder to isolate though, my simple test cases will pass but more complex will lead to guru. I'll let you know if I manage to isolate the problem to something specific!
jarp is offline  
Old 21 July 2017, 19:31   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 44
Posts: 23,244
Use this executable: http://www.winuae.net/files/b/winuae.7z (source tree is not complete, there is some stuff that is too broken to be commited.. also some recent fix is not yet there)
Toni Wilen is offline  
Old 21 July 2017, 20:46   #5
jarp
Registered User

 
Join Date: Apr 2016
Location: Helsinki / Finland
Posts: 175
This version works well. I ran through all my test cases and found no problems. Everything runs fine, all fpu instructions seems to behave fine and I use almost all of them.

So million thanks Toni, now I can move my development to 040 CPU setting, it offers some other benefits for me.
jarp is offline  
Old 21 July 2017, 22:48   #6
jarp
Registered User

 
Join Date: Apr 2016
Location: Helsinki / Finland
Posts: 175
Actually, I think I found one further bug which is not present in stable release. It can be reproduced using this code:

Code:
ExecBase			equ		$04
LVOSupervisor		equ		-$1e
LVOOpenLibrary		equ		-$228
LVOVPrintf			equ		-$3ba

WriteOutput macro
	movea.l		DosBase,a6
	move.l		\1,d1
	move.l		\2,d2	
	jsr			LVOVPrintf(a6)
endm

Main	
	movea.l		ExecBase,a6
	lea.l		DosName,a1 
	move.l		#36,d0 
	jsr			LVOOpenLibrary(a6)
    move.l		d0,DosBase
	
	jsr			GetVbrBase
	lea.l		HandleException(pc),a1
	move.l		a1,$2c(a0)

	fcmp		#100,fp0
	move.l		d6,Argv
	WriteOutput	#Fmt,#Argv
	
	rts
	
GetVbrBase
	movem.l		a5/a6,-(sp)
	movea.l		ExecBase,a6
	lea.l		.GetVbrRegister(pc),a5
	jsr			LVOSupervisor(a6)
	movem.l		(sp)+,a5/a6
	rts	
	
	; Read the vbr register
	.GetVbrRegister:
	movec		vbr,a0
	rte
	
HandleException
	move.l		$0c(sp),d7
	move.l		$02(sp),d6
	sub.l		d7,d6
	addi.l		#6,d7
	move.l		d7,$02(sp)
	rte

Constants
	DosName:	dc.b	"dos.library",0
	DosBase:	dc.l	0
	Fmt:		dc.b	"PC offset: %ld",10,0
	Argv:		dc.l	0,0,0,0,0,0,0,0
This code prints out "PC offset: 6" with 040 CPU setting in WinUAE 3.5.0 but "PC offset: 4" in latest WinUAE beta. ATM I do not have real LC/EC040 at hand, but if I understood correctly, real LC/EC040 should print 6.

As you can see from the code, what I do is that I check what stack frame contains at offset $02. According to manual 040 stack frame should contain "program counter" there but now the value seems to point to the data after the faulted instruction.

$0c contains "pc of faulted instruction" and that is ok. That's why my tests run fine, ATM I use it (because 030 had only it, though at offset $02, of course, to make stack frames incompatible like you said...) and manually calculate address of next instruction based on faulted instruction.

Thanks again!

Last edited by jarp; 21 July 2017 at 22:55.
jarp is offline  
Old 22 July 2017, 11:05   #7
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 44
Posts: 23,244
And more fixes.. (Not that trivial when instruction needs to be "executed" so that PC advances correctly, depending on EA, without actually doing anything and breaking anything else)

- wrong stack frame pc if fpuop #imm,fpx
- wrong stack frame pc if fpuop fpx,<ea> and ea needed extension words
- wrong stack frame ea if fpuop fpx,<ea>
- partially invalid fpu instruction (for example unsupported ea mode/reg bit field) generated unimplemented floating point instruction stack frame instead of normal f-line stack frame.
Toni Wilen is offline  
Old 22 July 2017, 14:31   #8
jarp
Registered User

 
Join Date: Apr 2016
Location: Helsinki / Finland
Posts: 175
Thank you Toni, amazing work! I switched to $02 program counter from stack frame and re-ran all my test cases and they performed fine. You've helped me a lot, thanks a million!

I'll let you know if I encounter any further problems...
jarp 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
Exception error running WHDLoad petee1979 project.WHDLoad 2 18 September 2016 17:02
WHDLoad Exception while running Monkey Island 2 carloratm project.WHDLoad 7 26 March 2014 21:17
2700b7+ Exception 3 with 68000 more compatible PeterK support.WinUAE 2 11 January 2014 21:16
Exception 0 vriviere support.WinUAE 9 25 June 2012 15:36
** CHK Exception ** CmdrVimes Coders. General 2 17 September 2010 17:14

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 14:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.08768 seconds with 13 queries