RE: poke - peek Speed?

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

> Yes, it is correct, because I will provide to it numbers in the range 0 
> -
> 32767. But you are right: I am performing less calculations than the 
> poke4 -
> peek version. However, the poke4 - peek version surely works by shifting
> instead of dividing, or merely moving bytes around, so it should be 
> faster.
> Don't you think so?

Ahh yes, with only that number range the algo is indeed correct.  The 
poke4 - peek version doesnt work by either shifting or dividing.  poke4 
writes a single 32 bit dword from any memory address where poke reads 8 
bit byte values (in this case two of them).  It is simply direct memory 
access with no math involved.

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.

function to2bytesa(integer u)
    poke4(Addr1, u)
    return( peek(Addr1) & peek(Addr1+1) )
end function

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

Search



Quick Links

User menu

Not signed in.

Misc Menu