[A89] Re: Quite in here... let's discuss something!


[Prev][Next][Index][Thread]

[A89] Re: Quite in here... let's discuss something!




I have some remarks to your optimalisations.

>
> This code could:
>
> > putSprite_loop1:
> >  clr.l d4
> >  move.w (a0)+,d4
> >  swap d4
> >  lsr.l d3,d4
> >  eor.l d4,(a1)
> >  lea 30(a1),a1
> >  dbra d2,putSprite_loop1
> >  rts
>
> could be optomized into:
>
>  moveq #30,d5 ;

I see, you think adda.l d5,a1 is faster than lea 30(a1),a1, but they are
both 8 clocks. So this isnt really useful.

> putSprite_loop1:
>  move.w (a0)+,d4
>  swap d4
>  clr.w d4

Indeed, if you switch some instructions clr.w can be used instead of clr.l.
But, as I mentioned before, if you use moveq #0,d4, d4 is also cleared in 4
clocks.

>  lsr.l d3,d4
>  eor.l d4,(a1)
>  add.l d5,a1  ;or maybe an add.w ?

Add.w is also OK, but it's both 8 clocks. I will explain the adding thing
here. There's a difference between adding to data registers and to address
register. When adding a word to a data register, it's a 16-bit addition and
only the lower 16-bits of the data register are altered.

But when adding to address registers, the source operand is sign-extended to
32-bits, and then that 32-bits are added to the 32-bit address register.
Here's an example:

            add.w #1,d0:       add.l #1,d0:     adda.w #1,a0         adda.l
#1,a0
before      d0=1234FFFF        d0=1234FFFF      a0=1234FFFF
a0=1234FFFF
after       d0=12340000        d0=12350000      a0=12350000
a0=12350000

So, when the source operand of ADDA can be 16-bits, use adda.w. I recommend
you (and i recommend it to everyone) to order the motorola 68K books
(UM+PM). That ordering is so cool, it's absolutely free to all over the
world! Here's the URL:

http://merchant.hibbertco.com/servlet/mtrlext.MtrlExtServlet?tp=search

and search for 68000 in the description field.

I hope you learned something from this.

Good luck,
Cheiz


>  dbra d2,putSprite_loop1
>  rts




Follow-Ups: References: