[sdiy] Pointers in C
Paul Maddox
yo at vacoloco.net
Sat Dec 31 15:23:40 CET 2011
Neil,
> The better approach would be the the shift-and-mask suggested by Olivier. And on an ARM this could well be faster too since the 4-byte int would be loaded in one memory operation, and shifting right is a single-cycle pass through the barrel-shifter. Something like:
I'm currently using a shift/mask approach and it's taking up valuable clock cycles.
I'm using an AVR, which is 8 bit, as such it seems to me to make far more sense to use pointers to locations in RAM as I can't just load a 32 bit word in one clock.
> Or if you just have the unsigned long itself then you don't need to mess with pointers, but still need to unpack it a byte at a time.
The need for the bytes, is that the address bus is attached to three 8 bit ports :)
so loading a long, shifting it and copying bytes out, then copying them to a port is lengthy process.
if I can copy them straight from RAM to the port register, it should be quicker.
Thanks for all them help guys, much appreciated.
Paul
______________________________________
VacoLoco
http://VacoLoco.net
More information about the Synth-diy
mailing list