Hey all,
I know it is possible to integrate some assembler code in Avrco. But I know nothing about assembler and need a very short piece of assembler to optimize for speed. Can someone help and take a look?
I try to multiplex a small RGB display with a xmega256A3u. I have a pointer to ram where the data is located, I have a free output port D and a free clock pin on a different port.
The assembler only need to get the ram byte at the pointer, increment the pointer, and place the data on the output port. Than it needs to set the clock pin high and low again.
I've a example from internet in C but like mentioned, I never used assembler in avrco or with the AVR so it's chinese for me Seems they do it in just 5 ticks :confused2:
Example:
// A tiny bit of inline assembly is used; compiler doesn't pick
// up on opportunity for post-increment addressing mode.
// 5 instruction ticks per 'pew' = 160 ticks total
#define pew asm volatile(
"ld __tmp_reg__, %a[ptr]+" "nt"
"out %[data] , __tmp_reg__" "nt"
"out %[clk] , %[tick]" "nt"
"out %[clk] , %[tock]" "n"
:: [ptr] "e" (ptr),
[data] "I" (_SFR_IO_ADDR(DATAPORT)),
[clk] "I" (_SFR_IO_ADDR(SCLKPORT)),
[tick] "r" (tick),
[tock] "r" (tock));
// Loop is unrolled for speed:
pew pew pew pew pew pew pew pew
pew pew pew pew pew pew pew pew
pew pew pew pew pew pew pew pew
pew pew pew pew pew pew pew pew
Thanks all for any help and information :thumbright:
I know it is possible to integrate some assembler code in Avrco. But I know nothing about assembler and need a very short piece of assembler to optimize for speed. Can someone help and take a look?
I try to multiplex a small RGB display with a xmega256A3u. I have a pointer to ram where the data is located, I have a free output port D and a free clock pin on a different port.
The assembler only need to get the ram byte at the pointer, increment the pointer, and place the data on the output port. Than it needs to set the clock pin high and low again.
I've a example from internet in C but like mentioned, I never used assembler in avrco or with the AVR so it's chinese for me Seems they do it in just 5 ticks :confused2:
Example:
// A tiny bit of inline assembly is used; compiler doesn't pick
// up on opportunity for post-increment addressing mode.
// 5 instruction ticks per 'pew' = 160 ticks total
#define pew asm volatile(
"ld __tmp_reg__, %a[ptr]+" "nt"
"out %[data] , __tmp_reg__" "nt"
"out %[clk] , %[tick]" "nt"
"out %[clk] , %[tock]" "n"
:: [ptr] "e" (ptr),
[data] "I" (_SFR_IO_ADDR(DATAPORT)),
[clk] "I" (_SFR_IO_ADDR(SCLKPORT)),
[tick] "r" (tick),
[tock] "r" (tock));
// Loop is unrolled for speed:
pew pew pew pew pew pew pew pew
pew pew pew pew pew pew pew pew
pew pew pew pew pew pew pew pew
pew pew pew pew pew pew pew pew
Thanks all for any help and information :thumbright: