English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 21 March 2011, 14:17   #1
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Help me debug my shitty code?

I've got a bit of an issue with my music disk. It's nearly finished now and I've done all the work on the boot sector and graphical intro while the first tune is loading. However, it seems somewhere between me adding the intro and writting it to track loader, its now incompatible with the 68000!.

Using the basic A600 config, it gets to the point where its about to fire up the music engine and crashes. If I change the CPU to a 68020, it works fine.

If anyone fancys giving me a hand, I can send you the ADF.

Cheers
h0ffman is offline  
Old 21 March 2011, 14:27   #2
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,046
Quote:
Originally Posted by h0ffman View Post
I've got a bit of an issue with my music disk. It's nearly finished now and I've done all the work on the boot sector and graphical intro while the first tune is loading. However, it seems somewhere between me adding the intro and writting it to track loader, its now incompatible with the 68000!.

Using the basic A600 config, it gets to the point where its about to fire up the music engine and crashes. If I change the CPU to a 68020, it works fine.

If anyone fancys giving me a hand, I can send you the ADF.

Cheers
Perhaps you using 68020+ commands or odd address error occured, check the guru number for info.
Don_Adan is offline  
Old 21 March 2011, 14:31   #3
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Error: 8000 0003 <-???
Task: 000fff6a

Ahhh, googling states that 3 means odd address... hmmm... thought I fixed all them!

Any idea how to trap this before it happens with the WunUAE debugger?

Last edited by h0ffman; 21 March 2011 at 14:36. Reason: more info
h0ffman is offline  
Old 21 March 2011, 15:23   #4
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Hey h0ffman - as always mate, I can try and help out.

Feel free to send it over to the usual place

Are you assembling with Devpac...? Do you use an rsreset structure...?

If you have something at an odd address in that kind of structure Devpac will assemble code that'll run OK but will crash with odd address errors when run as a pc relative binary trackloaded from an .adf. I had the same thing myself once... I can only assume Devpac corrects the problem in the background but doesn't announce it's done so == bad in my opinion.

EDIT: also, obviously check for using 'even' (or cnop 0,2 ) statements after any .b data to keep everything word aligned...

Last edited by pmc; 21 March 2011 at 15:29. Reason: Added something...
pmc is offline  
Old 21 March 2011, 16:22   #5
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by h0ffman View Post

Any idea how to trap this before it happens with the WunUAE debugger?
You could patch the address error exception vector ($C) and check the stack once it's triggered.
StingRay is offline  
Old 21 March 2011, 17:22   #6
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by StingRay
You could patch the address error exception vector ($C) and check the stack once it's triggered.
Ah, cool.

I'm gonna try doing that type of thing next time something of mine crashes, will be interesting.

Back to the original question: Just dropped you a reply h0ffman - depending on the emulated setup I use I either get a crash with no guru or a freeze with no crash. Both happen in different places though...

Last edited by TCD; 21 March 2011 at 17:27. Reason: Back-to-back posts merged. Use the edit function.
pmc is offline  
Old 21 March 2011, 17:44   #7
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Right, trapped that... what on earth is on the stack at that point and how to I find out where it was???
h0ffman is offline  
Old 21 March 2011, 18:59   #8
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by h0ffman View Post
Right, trapped that... what on earth is on the stack at that point and how to I find out where it was???
Exception stack frame on 68000:

dc.w status register
dc.l PC

Thus it's easy to find out where the offending instruction is (move.l 2(a7),a0 -> a0 points to next instruction).

See Section 6 in the 68000 manual for more info.
StingRay is offline  
Old 22 March 2011, 00:12   #9
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Problem solved, i think.. me being a retard forgot to set the stack pointer! Just ran some tests and all appears to be cool now. That will explain why there was garbage on the stack when it crashed rather than a pointer.
h0ffman is offline  
Old 22 March 2011, 00:29   #10
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by h0ffman View Post
Problem solved, i think.. me being a retard forgot to set the stack pointer!
Doesn't explain why it worked on 68020.

Quote:
Originally Posted by h0ffman View Post
That will explain why there was garbage on the stack when it crashed rather than a pointer.
I don't think so.
StingRay is offline  
Old 22 March 2011, 00:57   #11
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
my 68020 setup has 8 meg fast ram, thus keeping the stack well out of reach. Either way, its working, with NEW bugs!
h0ffman is offline  
Old 22 March 2011, 15:00   #12
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Right think I finally crack the issue, and funilly enough it wasn't in my code!

Whats wrong with this picture....
Code:
CIA_AddCIAInt	move.l	d0,CIA_CIASeed
		move.l	a0,CIA_VBR
		lea.l	$dff000,a6
		move.w	#$a000,$9a(a6)		; Enable CIA interrupt (Level6)

		move.l	CIA_CIASeed,d0
		divu.w	#125,D0 		; Defaults to 125 BPM

		move.b	d0,CIA_TimerLo
		lsr.w	#8,d0
		move.b	d0,CIA_TimerHi
	
		move.l	CIA_VBR,a0
		move.l	CIA_CIAVector(a0),CIA_OldIntCode
		move.l	#CIA_IntCode,CIA_CIAVector(a0); Set interrupt vector
4th line down! Activating the interrupt before setting the pointer!!!!!

I'm guessing on the 020, the instructions are in the cache, so it speeds through them before the CIA gets activated. When ran from system environment, even if the old CIA gets executed, the system is still there, thus it doesn't crap out.

So, we are onward bound again.....

Last edited by h0ffman; 22 March 2011 at 15:00. Reason: rah
h0ffman is offline  
Old 22 March 2011, 15:08   #13
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
A few minutes ago I checked your code and found exactly that problem too, lev6 still contains the OS interrupt at this point which is of course not a good idea. Also proves that I was right with my assumption that it wasn't stack related.
StingRay is offline  
Old 22 March 2011, 15:17   #14
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Yep, stack issue only affected A500+ because its as low as $2000 when its running through the boot block. I was decrunching my data over the top of it!!
h0ffman 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
Debug log trap vriviere support.WinUAE 1 01 July 2010 14:27
Hisoft C++ Debug AlfaRomeo Coders. General 0 13 October 2008 21:17
Mame32 Debug redblade Retrogaming General Discussion 4 10 October 2005 05:43
Debug ? mtb support.WinUAE 8 19 December 2002 12:19
Avoid debug output? Flinx support.WinUAE 0 23 July 2002 09:35

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 05:36.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14894 seconds with 12 queries