English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 13 January 2020, 13:26   #1
KONEY
OctaMED Music Composer

KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 45
Posts: 422
Help with badly breaking line of code

I'm stuck with a small piece of code which breaks badly on 16 bit machines. With "badly" I mean that it will compile but once executed everything would stuck and needs a reboot.

The code works OK on my A600 with Vampire and on an emulated A3000 but breaks on a real A500 or an emulated one therefore I think it's a problem with 16 bit machines.

the line of code is MOVE.L (A2)+,(A3) so nothing strange, I've been asking to some demoscene guy who told me there should be no problem executing this on any Amiga.

Here the complete routine:

Code:
PRINT:
	LEA	BITPLANE,A3	; Indirizzo del bitplane destinazione in a3
	MOVE.L	#KONEY,A2
	CLR	D6
	MOVE.B	#4,D6		; RESET D6
	ADD.W	#40*115,A3	; POSITIONING

LOOP:				; LOOP KE CICLA LA BITMAP
	ADD.W	#15,A3
	MOVE.L	(A2)+,(A3)	
	ADD.W	#25,A3
	DBRA	D6,LOOP
	RTS
And here the complete source:
https://github.com/KONEY/asm68k-test...OGOBPM_ANIM2.s

Any hint would be appreciated!!
KONEY is offline  
Old 13 January 2020, 13:29   #2
KONEY
OctaMED Music Composer

KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 45
Posts: 422
forgot to say this is just an ASM exercise which I'm slowly learning
KONEY is offline  
Old 13 January 2020, 13:31   #3
Hedeon
PPC Hacker

 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,220
Not entirely sure, but doesn't the 68000 need 16 bit alignment when writing 32 bits? And seeing you are adding uneven numbers to A3 it fails on that?
Hedeon is offline  
Old 13 January 2020, 13:35   #4
sparhawk
Registered User

sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 51
Posts: 321
The problem is this line!
Code:
ADD.W	#15,A3
On 68000 (10/20 as well?) the data needs to be on an even address for word or longword access, so this will cause a guru. On higher CPUs this will work, but causes a speed penality.

Another thing that I find strange is that you do
Code:
LEA	BITPLANE,A3
This means that your "bitplane" is defined in your source, right? But the bitplane must be located in chipmem, so if this is just a buffer, this is fine. If this is really a bitplane to be displayed, you must make sure that it is in chipmem.

Last edited by sparhawk; 13 January 2020 at 13:42.
sparhawk is offline  
Old 13 January 2020, 13:37   #5
Hedeon
PPC Hacker

 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,220
020 should be fine. Not sure about the 010.
Hedeon is offline  
Old 13 January 2020, 13:44   #6
Hedeon
PPC Hacker

 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,220
Quote:
Originally Posted by sparhawk View Post
This means that your "bitplane" is defined in your source, right? But the bitplane must be located in chipmem, so if this is just a buffer, this is fine. If this is really a bitplane to be displayed, you must make sure that it is in chipmem.
He defines BSS_C for the bitplane
Hedeon is offline  
Old 13 January 2020, 13:57   #7
KONEY
OctaMED Music Composer

KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 45
Posts: 422
YES that was the problem!!! Actually you can do the addition with odd values but further operations on the A register would make everything crash... I was focusing on the wrong line but I definitely learnt a lesson today. Thanks Hedeon and thanks to everyone!

Quote:
Originally Posted by Hedeon View Post
Not entirely sure, but doesn't the 68000 need 16 bit alignment when writing 32 bits? And seeing you are adding uneven numbers to A3 it fails on that?
KONEY is offline  
Old 13 January 2020, 13:58   #8
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 1,897
Simple code like that* which works for the 68020/68030 but fails on the 68000 almost always means using odd addresses somewhere in the code. The 68000 can only read or write bytes to and from odd addresses. For all other operand sizes addresses need to be even.

... And now I see that someone already wrote that... Should've read the thread first. Anyway, sparhawk is correct - you can't add an odd number of bytes to an address in a loop when using move.w or move.l to or from that address.

*) as in code that does not use any instruction that only works on the 68010+.
roondar is offline  
Old 13 January 2020, 14:02   #9
sparhawk
Registered User

sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 51
Posts: 321
Quote:
Originally Posted by KONEY View Post
YES that was the problem!!! Actually you can do the addition with odd values but further operations on the A register would make everything crash...

Yes. of course. You can have an address register with an odd value. You just can't use this address to access word or longs.


so this is fine:

Code:
move.l #1,a0
.loop:
   move.b (a0)+,d0
   bne .loop

But this would crash:

Code:
move.l #1,a0
.loop:
   move.w/l (a0)+,d0
   bne .loop
Actually, thereotically you could write a trap handler, which catches this, and fixes the access, but that would not be a good idea in the usual case.
sparhawk is offline  
Old 13 January 2020, 14:42   #10
Hedeon
PPC Hacker

 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,220
Quote:
Originally Posted by KONEY View Post
Actually you can do the addition with odd values but further operations on the A register would make everything crash...
That's what I meant :-) Adding an uneven number to A3 would lead to 32 bit access to a non-16 bit alligned address. Glad to have been of some help.
Hedeon 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
Resource : modifying a line of code kamelito support.Apps 7 28 December 2017 11:25
The most badly cracked Amiga game Swordlord support.Games 215 16 July 2013 23:47
breaking plastic, breaking RF shield flaps lost_lemming support.Hardware 5 18 February 2010 13:39
Need a file badly! blade002 request.Apps 9 03 November 2008 08:16
help badly needed jimmyjock New to Emulation or Amiga scene 4 29 November 2003 00:55

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 04:59.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.07591 seconds with 15 queries