Shop OBEX P1 Docs P2 Docs Learn Events
1 cycle/long memory zero - Page 2 — Parallax Forums

1 cycle/long memory zero

2»

Comments

  • TonyB_TonyB_ Posts: 2,178
    edited 2021-03-28 00:10

    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
    
  • evanhevanh Posts: 15,912

    Nice trick. Though only saves the mask data.

  • TonyB_TonyB_ Posts: 2,178
    edited 2021-03-28 00:29

    @evanh said:
    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.

  • cgraceycgracey Posts: 14,151

    Good ideas.

  • evanhevanh Posts: 15,912
    edited 2021-03-28 00:50

    @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 = x
          wrlong  #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_TonyB_ Posts: 2,178
    edited 2021-03-28 11:37

    @evanh said:

    @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 = x
            wrlong  #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.

  • evanhevanh Posts: 15,912

    SETQ's are single operand, plenty of opcode space for more of those instructions.

  • evanhevanh Posts: 15,912

    @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.

Sign In or Register to comment.