RE: poke - peek Speed?

new topic     » goto parent     » topic index » view thread      » older message » newer message

> > The slow up (as pointed out by Mr Craig) is this line:
> > return( peek({Addr1,2}) )
> > 
> > I dont really understand the difference between peek({Addr1,2}) and 
> > peek(Addr1) & peek(Addr1+1), they both build a sequence.  But 
> > the second 
> > version just about matches the results you would expect so 
> > internally it 
> > must be be more efficient.
> 
> It's not the return sequence, but the sequence: {Addr1,2} that's the
> problem.  Rob's suggestion was to do this:
> 
> sequence peek2addr
> peek2addr = {Addr1,2}
> 
> function to2bytesa(integer u)
>     poke4(Addr1, u)
>     return peek( peek2addr )
> end function
> 
> Matt Lewis

Ahh, thanks Matt =)
I didnt quite get what he was refering to.  Thats quite a good 
improvement.  I dont know if removing the sequences completely will 
break the rest of your program, but without them there is another 
difference in speed...

integer lobyte
integer hibyte
procedure to2bytesD(integer u)
     poke4(Addr1, u)
     lobyte = peek(Addr1)
     hibyte = peek(Addr1+1)
end procedure

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu