Improved way to fill hub RAM with 32-bit value in reg x (preserved):
'fill hub RAM with 32-bit value in x'N.B. x is not changed, AUGD mask long avoidedsetd .xlo,x
mov .xhi,x
sets .xhi,#511ror .xhi,#9setq #len-1
.xhi augd #0-0
.xlo wrlong #0-0,ptra
SETS immediate could be changed for conditional AUGD.
EDIT:
Could save 4 longs in future with a new D-only AUGDR instruction:
'AUGDR does not exist yet!setq #len-1
augdr x 'next #D = xwrlong #0-0,ptra
@TonyB_ said:
EDIT:
Could save 4 longs in future with a new D-only AUGDR instruction:
'AUGDR does not exist yet!setq #len-1
augdr x 'next #D = xwrlong #0-0,ptra
I'd pondered that as well. But it's a very specific use, one that WRLONG the block copy hadn't been designed for even. Very few instructions would use such a prefix, not even RDLONG.
EDIT: Would be better to have a block filling mechanism that didn't need double prefixing like that. Ie: SETQ3 that doesn't increment the cog register pointer.
@TonyB_ said:
EDIT:
Could save 4 longs in future with a new D-only AUGDR instruction:
'AUGDR does not exist yet!setq #len-1
augdr x 'next #D = xwrlong #0-0,ptra
I'd pondered that as well. But it's a very specific use, one that WRLONG hadn't been designed for even. Very few instructions would use such a prefix, not even RDLONG.
EDIT: Would be better to have a block filling mechanism that didn't need double prefixing like that. Ie: SETQ3 that doesn't increment the cog register pointer.
Filling hub RAM with arbitrary values is very important. The quickest way to fill a block of cog registers currently is via hub RAM using fast block write immediate then fast block read, assuming block size is too big for hard-coding lots of 2-cycle MOVs.
I agree that it would be better to avoid AUGD entirely. Maybe use SETQ/SETQ2 with Q[31]=1 to stop reg/LUT pointer incrementing.
Wuerfel_21's original code rotates the fill register. Rotating it back costs a long, so my suggestion saves two longs overall.
@TonyB_ said:
Wuerfel_21's original code rotates the fill register. Rotating it back costs a long, so my suggestion saves two longs overall.
Oh, the span_color, I'd missed that somehow. And reading further back, it has indeed been copied from poly_color. So there is one more instruction in Wuerfel's code I hadn't counted.
Comments
Improved way to fill hub RAM with 32-bit value in reg x (preserved):
'fill hub RAM with 32-bit value in x 'N.B. x is not changed, AUGD mask long avoided setd .xlo,x mov .xhi,x sets .xhi,#511 ror .xhi,#9 setq #len-1 .xhi augd #0-0 .xlo wrlong #0-0,ptra
SETS immediate could be changed for conditional AUGD.
EDIT:
Could save 4 longs in future with a new D-only AUGDR instruction:
'AUGDR does not exist yet! setq #len-1 augdr x 'next #D = x wrlong #0-0,ptra
Nice trick. Though only saves the mask data.
Not only that, Evan, reg containing fill value is preserved.
Also applicable to AUGS that is patched.
Wuerfel's original preservers it too - https://forums.parallax.com/discussion/comment/1517875/#Comment_1517875
Good ideas.
I'd pondered that as well. But it's a very specific use, one that WRLONG the block copy hadn't been designed for even. Very few instructions would use such a prefix, not even RDLONG.
EDIT: Would be better to have a block filling mechanism that didn't need double prefixing like that. Ie: SETQ3 that doesn't increment the cog register pointer.
Filling hub RAM with arbitrary values is very important. The quickest way to fill a block of cog registers currently is via hub RAM using fast block write immediate then fast block read, assuming block size is too big for hard-coding lots of 2-cycle MOVs.
I agree that it would be better to avoid AUGD entirely. Maybe use SETQ/SETQ2 with Q[31]=1 to stop reg/LUT pointer incrementing.
Wuerfel_21's original code rotates the fill register. Rotating it back costs a long, so my suggestion saves two longs overall.
SETQ's are single operand, plenty of opcode space for more of those instructions.
Oh, the span_color, I'd missed that somehow. And reading further back, it has indeed been copied from poly_color. So there is one more instruction in Wuerfel's code I hadn't counted.