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


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

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




What I have always wondered is if those clock cycles given in various books 
takes into account the time to fetch the instructions from ram.  They might 
just be how long they take to acomplish in the processor once the instruction 
fetch is done.  So if you can reduce the code in the loop, then you have 
reduced the time in the instruction fetches, and so the loop runs faster.  So 
then the moveq #30,dx would be an optomization.





Quoting Gijs Leegwater <g_leegwater@hotmail.com>:

> 
> 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
> 
> 



23 He (Elisha) went up from there to Bethel; and while he was going up on 
the way, some small boys came out of the city and jeered at him saying, 
"Go away, baldhead!  Go away, baldhead!  24 When he turned around and saw 
them, he cursed them in the name of the lord.  Then two she-bears came 
out 
of the woods and mauled forty-two of the boys.  25 From there he went on 
to Mount Carmel, and then returned to Samaria.

	- 2 Kings 2: 23-25



Follow-Ups: References: