[hatari-devel] Re: DSP addressing bug |

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]

*To*: hatari-devel@xxxxxxxxxxxxxxxxxxx, Laurent Sallafranque <laurent.sallafranque@xxxxxxx>*Subject*: [hatari-devel] Re: DSP addressing bug*From*: Douglas Little <doug694@xxxxxxxxxxxxxx>*Date*: Wed, 21 Oct 2015 13:54:31 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=FuRYBCQUQMxrOmonFuSvnBKJxubeJqh2ferOdxXHty4=; b=Yd5ijlxWrKjRbrgCCNF6U1G1aNIhLoht8T4q2yrqLjg7Jc5ChXso5GAI3V+1b9xRn2 boFBWcSINXdq4qzAeH5YwSADBMERx9Ros8WqC1y2mLlyPvXcM8gm/LAFcRF/hnELEMpX B1wpWy16C5BbBJ/GSIPBvQrifSnsaAC6S2Aj4b+qqJd4d+y4CH1Oiz6R+fRoVA/7WXfa x/zvPMXXBKnHazUPi7AW1cLLrhLa9328XosFyZ26y1lMdVD1ywQRWGeG0cqfgFG9ppKe Brvb0jWvO9H7e3SiATsAOSE0jxinVnXKYsq8SiV5VzxOlWNyuijT5a+jPKIbOPb6yDJy ivbw==

Hi,

This one is almost certainly for Laurent.i.e. a normal address update (Rn)+ performs ringbuffer addressing where (Rn)+Nn lets you advance to the next ringbuffer without any modulo... or alternatively (Rn+Nn) allows addressing of equal position in a different ringbuffer.

another example:

Rn = 0

Nn = 8

Mn = 3-1 ; (addr % 3)

; normal wrapping behaviour...

(Rn)+ ; 0->1

(Rn)+ ; 1->2

(Rn)+ ; 2->0

(Rn)+ ; 0->1

; now advance to new ringbuffer

(Rn)+Nn ; 1->9 (1+8 = 9)

..since Nn=8 is twice the 2^k ringbuffer bound of 4, for a mod of 3)

Here Hatari yields a different answer, having performed modulo on the +Nn update instead of a normal increment by Nn.

..since Nn=8 is twice the 2^k ringbuffer bound of 4, for a mod of 3)

Here Hatari yields a different answer, having performed modulo on the +Nn update instead of a normal increment by Nn.

I have been using a (rather expensive) temporary workaround which looks a bit like this:

move #-1,m1 ; 2 or 4c : disable ring mode

nop ; 0 or 2c

move (r1)+n1 ; 2c

move #3-1,m1 ; 2 or 4c : restore ring mode

...instead of the intended...

move (r1)+n1 ; 2c

.

.

Note that this trick only works when Nn is a multiple of the 2^k ringbuffer bound. In any other case it just wraps.

On 9 July 2015 at 10:27, Douglas Little <doug694@xxxxxxxxxxxxxx> wrote:

> move (r1)+n1m1: 2 (3-1, or modulo=3)n1: 8r1: $4020Hi,Since this is a DSP behaviour thing, it might be one for Laurent!I ran into this case recently and it appears to be a bug (I think). I see something funny when performing an address update in modulo/ringbuffer mode...r1: $4025I think r1 should actually read $4028 because there is a special case when +Nn increment is used in modulo mode, where N is a multiple of the 2^n modulo upper bound.I have actually used this before successfully but in that case the Mn register was set to produce a 2^n modulo (i.e. modulo = 4, buffer size = 4).. That appeared to work correctly at the time.

In this case the modulo is odd (modulo = 3, buffer size = 4) and the result is weird.

Another curious thing is that the earlier case which worked used Nn exactly the size of the ringbuffer (using Nn=Mn+1), and produced this (correct) result in both HW and Hatari:

r1: $0100

n1: 4

m1: 3 (4-1, or modulo=4)

> move (r1)+n1

r1: $0104...however this is what I get with Hatari using Nn=Mn+1 with the odd modulo.

r1: $0100

n1: 4

m1: 2 (3-1, or modulo=3)

> move (r1)+n1

r1: $0101The latter hasn't been confirmed on real HW so I'm less sure about it being a bug. However the updated address should land in the *next* ringbuffer not the current one (using the special rules for +/-Nn updates) so it also seems suspect.

So it seems like 'bug' is as follows:

The modulo is still being applied when Nn = P x 2^k, when it should be ignored.TBH I haven't been able to test the bug cases on HW yet because it is temporarily packed away :( but I will as soon as I can. The manual does seem to explain it with a diagram though (attached).

If an offset, Nn, is used in the address calculations, the 16-bit absolute value, INnl, must be less than or equal to M for proper modulo addressing. If Nn>M, the result is data dependent and unpredictable,(see Figure 5-12).except for the special case where Nn = P x 2k, a multiple of the block size where P is a positive integer.For this special case, when using the (Rn) + Nn addressing mode, the pointer, Rn, will jump linearly to the same relative address in a new buffer, which is P blocks forward in memory

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [hatari-devel] Re: Hatari SCSI Driver patch** - Next by Date:
**Re: [hatari-devel] Feedback SDL2 support** - Previous by thread:
**Re: [hatari-devel] Re: Hatari SCSI Driver patch** - Next by thread:
**[hatari-devel] unsubscribe**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |