Shop OBEX P1 Docs P2 Docs Learn Events
PNut/Spin2 Latest Version (v46 - DEBUG gating, clock-setter control, VAR flexibility, C_Z for DEBUG) - Page 44 — Parallax Forums

PNut/Spin2 Latest Version (v46 - DEBUG gating, clock-setter control, VAR flexibility, C_Z for DEBUG)

1414244464765

Comments

  • evanhevanh Posts: 15,915

    Okay, that would be extraneous action then. How come you even noticed it?

  • cgraceycgracey Posts: 14,151

    I don't think I use Prop_Clk during download.

    Surac, can you confirm that the clock is actually going to the _CLKFREQ frequency in a PASM-only download? It should remain in RCFAST mode at ~24MHz. In a Spin2 download, the _CLKFREQ frequency will be set when the interpreter starts, just before your program starts. All downloading is done at RCFAST, though.

  • SuracSurac Posts: 176
    edited 2021-03-31 13:21

    Surac, can you confirm that the clock is actually going to the _CLKFREQ frequency in a PASM-only download? It should remain in RCFAST mode at ~24MHz. In a Spin2 download, the _CLKFREQ frequency will be set when the interpreter starts, just before your program starts. All downloading is done at RCFAST, though.

    I tried again and found how to reproduce it:

    con 
        _clkfreq=100_000_000
    dat
        org 
        rep @done,#0
        drvnot #0
    done
    
    • Pressing F10 in PNUT gives a 6.5 MHz on pin 0 -> that is what i have expected. P2 is in RCFAST
    • But Pressing CTRL+F10 in PNUT gives 25 MHz on pin 0 -> P2 is in PLL mode 100 MHz
    con 
        _clkfreq=200_000_000
    dat
        org 
        rep @done,#0
        drvnot #0
    done
    
    • Pressing CTRL+F10 in PNUT gives 50 MHz on pin 0 -> P2 is in PLL mode 200 MHz

    As i know "Debug" needs the P2 to run >10MHz you just set the clock in den debugger to whatever is specified by _clkfreq=xxx. It seem to be a side effect of the DEBUG

  • ersmithersmith Posts: 6,052
    edited 2021-03-31 15:17

    (deleted, I had incorrect information)

  • cgraceycgracey Posts: 14,151

    I'm pretty sure I don't use Prop_Clk in PNut. There is no reason to, at this time, because our USB-to-serial chips only run reliably to 2Mbaud and RCFAST runs fast enough to support that.

    Ctrl-F10 sets the clock mode because it launches the debugger before running your PASM-only program.

  • @cgracey said:
    Ctrl-F10 sets the clock mode because it launches the debugger before running your PASM-only program.

    Yes, that's what i have found. Launching with debugger sets the clock to whatever is specified by _CLKFREQ even in PASM only Programs.

    sorry for thinking you are using Prop_Clk, that was wrong. It is the debugger setting the clock what tortured me

  • Thanks Chip.
    V35m command line tweaks are a real time saver. :smiley:

  • cgraceycgracey Posts: 14,151
    edited 2021-05-23 10:21

    I posted a new version (v35n) at the top of the this thread.

    Per Gavin of University of Virginia's request, sprites have been added to the DEBUG PLOT window.

    Also, REPEAT-variable now leaves the variable at the terminal value, instead of the terminal value +/- step.

    Gavin was having his students make video games using PLOT as a first exercise in using the P2. He had developed a sprite drawing routine, but it was too slow to be practical and inescapably more complicated than beneficial for the students. So, sprites are now built into PLOT and they can be rendered with a very terse command.

    ' Run with DEBUG enabled to view
    
    _clkfreq = 300_000_000
    
    sprites = 128
    
    VAR x[sprites], y[sprites], dx[sprites], dy[sprites], orient[sprites], scale[sprites], opacity[sprites]
    
    PUB go() | i
    
      debug(`plot myplot size 384 384 update)
      debug(`myplot cartesian 1)
    
      'load 32 sprites
      repeat i from 0 to 31
        debug(`myplot spritedef `(i) 16 16 `uhex_byte_array_(@Mario0 + i * 256, 256) `uhex_long_array_(@MarioColors, 52))
    
      'set sprite trajectories, orientations, scales, and opacities
      repeat i from 0 to sprites - 1
        x[i] := getrnd() zerox 8            '0..511
        y[i] := getrnd() zerox 8            '0..511
        dx[i] := getrnd() // 7          '-6..6
        dy[i] := getrnd() // 7          '-6..6
        orient[i] := getrnd() & 7           '0..7
        scale[i] := getrnd() +// 4 + 1      '1..4
        opacity[i] := getrnd() zerox 6 + 128    '128..255
    
      'animate sprites
      repeat
        debug(`myplot clear)
        repeat i from 0 to sprites - 1
          debug(`myplot set `((x[i] += dx[i]) & $1FF - 64, (y[i] += dy[i]) & $1FF - 64) sprite `(i & $1F, orient[i], scale[i], opacity[i]))
        debug(`myplot update)
        waitms(10)
    
    
    ' Thanks to Gavin T. Garner, Ph.D. of University of Virginia for these sprites.
    
    DAT
    
    Mario0 byte {
    }$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,{
    }$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,{
    }$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,{
    }$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,{
    }$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,{
    }$00,$00,$00,$00,$00,$00,$00,$19,$19,$19,$19,$00,$00,$00,$00,$00,{
    }$00,$00,$00,$00,$00,$19,$19,$1f,$1f,$18,$18,$19,$00,$00,$00,$00,{
    }$00,$00,$00,$00,$19,$1f,$1f,$1f,$1f,$1f,$18,$19,$00,$00,$00,$00,{
    }$00,$00,$00,$19,$21,$1f,$21,$21,$19,$19,$19,$19,$19,$19,$00,$00,{
    }$00,$00,$19,$21,$21,$21,$19,$19,$19,$19,$19,$19,$19,$19,$19,$00,{
    }$00,$00,$19,$21,$21,$19,$19,$11,$11,$11,$11,$19,$19,$19,$00,$00,{
    }$00,$19,$19,$19,$19,$19,$11,$09,$09,$19,$09,$19,$00,$00,$00,$00,{
    }$00,$19,$09,$09,$19,$19,$11,$09,$09,$19,$09,$19,$19,$19,$00,$00,{
    }$00,$19,$09,$09,$19,$19,$19,$11,$09,$09,$09,$08,$08,$08,$19,$00,{
    }$00,$19,$11,$09,$11,$19,$11,$09,$19,$11,$09,$09,$09,$09,$19,$00,{
    }$00,$00,$19,$11,$11,$11,$09,$19,$19,$19,$11,$11,$11,$19,$00,$00
    
    ....
    ..... 31 sprites not shown in this list, in order to fit it into this post .....
    
    MarioColors long {
    }%00000000_00000000_00000000_00000000,{  $7fff  'any bit 31..24 set means transparent
    }%11111111_11111000_11111000_11111000,{  $7fff
    }%11111111_11111000_11111000_11111000,{  $7fff
    }%11111111_11111000_11111000_11111000,{  $7fff
    }%11111111_11111000_11011000_10011000,{  $7f73
    }%11111111_11111000_11011000_10010000,{  $7f72
    }%11111111_11111000_11011000_01001000,{  $7f69
    }%11111111_11110000_11011000_01001000,{  $7b69
    }%11111111_11111000_11001000_10010000,{  $7f32
    }%11111111_11110000_10100000_01110000,{  $7a8e
    }%11111111_11111000_10010000_01101000,{  $7e4d
    }%11111111_11111000_10011000_00111000,{  $7e67
    }%11111111_11111000_10011000_00011000,{  $7e63
    }%11111111_11011000_10010000_01001000,{  $6e49
    }%11111111_01101000_10110000_11011000,{  $36db
    }%11111111_01100000_10101000_11100000,{  $32bc
    }%11111111_01001000_10010000_10110000,{  $2656
    }%11111111_11110000_10001000_01101000,{  $7a2d
    }%11111111_11101000_10010000_01001000,{  $7649
    }%11111111_10111000_01101000_00000000,{  $5da0
    }%11111111_10110000_01101000_00000000,{  $59a0
    }%11111111_01010000_10001000_10111000,{  $2a37
    }%11111111_01001000_01101000_10010000,{  $25b2
    }%11111111_01000000_01100000_10010000,{  $2192
    }%11111111_11111000_00110000_01010000,{  $7cca
    }%11111111_00110000_00110000_00110000,{  $18c6'***problem!
    }%11111111_11111000_00100000_01001000,{  $7c89
    }%11111111_11011000_00101000_00000000,{  $6ca0
    }%11111111_11111000_00001000_00001000,{  $7c21
    }%11111111_00100000_00100000_00100000,{  $1084
    }%11111111_11011000_00000000_00100000,{  $6c04
    }%11111111_11011000_00000000_00101000,{  $6c05 'address=31
    }%11111111_11111000_11111000_11111000,{  $7fff  00->20   'MarioItems
    }%11111111_11011000_11111000_11111000,{  $6fff  01->21
    }%11111111_11111000_11011000_00000000,{  $7f60  02->22
    }%11111111_10100000_11101000_00100000,{  $53a4  03->23
    }%11111111_11110000_11010000_10110000,{  $7b56  04->24
    }%11111111_11111000_11010000_10001000,{  $7f51  05->25
    }%11111111_11111000_11001000_11000000,{  $7f38  06->26
    }%11111111_11111000_10101000_00110000,{  $7ea6  07->27
    }%11111111_10000000_11000000_00110000,{  $4306  08->28
    }%11111111_11111000_10010000_00100000,{  $7e44  09->29
    }%11111111_11010000_10100000_00000000,{  $6a80  0a->2a
    }%11111111_10100000_01111000_00000000,{  $51e0  0b->2b
    }%11111111_01011000_10011000_00000000,{  $2e60  0c->2c
    }%11111111_11100000_01011000_00010000,{  $7162  0d->2d
    }%11111111_11111000_01001000_01001000,{  $7d29  0e->2e
    }%11111111_10011000_01001000_00000000,{  $4d20  0f->2f
    }%11111111_00110000_00110000_00110000,{  $18c6  10->30
    }%11111111_11111000_00101000_00100000,{  $7ca4  11->31
    }%11111111_11010000_00000000_00100000,{  $6804  12->32
    }%11111111_00100000_00100000_00100000  ' $1084  13->33 'address=51
    
  • evanhevanh Posts: 15,915
    edited 2021-05-23 10:14

    With just the humble comport, lol. I love it.

  • evanhevanh Posts: 15,915

    Not sure about changing the REPEAT variable outcome. The traditional way does have its use in that the variable is prep'd for continuation. It's the logical outcome of post-increment. When I watched the video, I was a little surprised at the question being posed really.

  • cgraceycgracey Posts: 14,151
    edited 2021-05-23 10:32

    @evanh said:
    Not sure about changing the REPEAT variable outcome. The traditional way does have its use in that the variable is prep'd for continuation. It's the logical outcome of post-increment. When I watched the video, I was a little surprised at the question being posed really.

    This will work properly now:

      repeat outa.[15..8] from 0 to 255
        'do something
    

    I think it is an improvement.

  • evanhevanh Posts: 15,915

    heh, yeah, especially in the Prop2 where very few special registers are both read and write. All the same, I can see the count as a constrained index is a decent example of the alternative. And I have coded such before.

  • That is just SERIOUSLY cool. That has sizzle!

  • Lol, Chip this is crazy good.
  • jmgjmg Posts: 15,173

    @evanh said:
    Not sure about changing the REPEAT variable outcome. The traditional way does have its use in that the variable is prep'd for continuation. It's the logical outcome of post-increment. When I watched the video, I was a little surprised at the question being posed really.

    I think the point was that Spin 1 does not do that, so Spin 2 should really follow the same behaviour.
    It is not common programming to expect a for loop variable to have a specific exit value (eg the loop may have a exit), but it certainly helps porting if Spin2 behaves exactly the same as Spin1. (where possible)

  • @ cgracey

    re:Per Gavin of University of Virginia's request, sprites have been added to the DEBUG PLOT window.

    Very cool!!

  • cgraceycgracey Posts: 14,151

    Would anyone mind if I got rid of the commas in DEBUG outputs? They are sometimes good to look at, but just take more time to transmit.

  • potatoheadpotatohead Posts: 10,261
    edited 2021-05-24 17:40

    Two thoughts:

    Where that output can be used, direct cut 'n paste style, that is a seriously great learning tool. The commas are worth keeping.

    If not, then maybe they are a waste.

    Personally, I would split the middle and have verbose, as intended above. People can cut 'n paste output / log lines and use them.

    And have minimal mode for performance.

  • jmgjmg Posts: 15,173
    edited 2021-05-24 20:17

    @cgracey said:
    Would anyone mind if I got rid of the commas in DEBUG outputs? They are sometimes good to look at, but just take more time to transmit.

    You mean make them optional ? Yes, that's a good idea. Anything that can shorten the character strings all helps, as in many cases those can feed straight into a USB buffer, and it all reduces the P2 time impact.

    Can I also suggest making hex-strings sticky in some way, so you do not need to send a HEX char with every number.
    Maybe if the command has a suffix $, then all chars following are taken as hex ?

    Addit:
    As a use example, in the past I've captured space or comma delimited hex strings, and pasted into a spreadsheet, then you can use HEX2DEC() to process those fields.
    Excel can import
    ,002D1AB8,005A2BF2
    or
    002D1AB8 005A2BF2

    Excel can even import this, if I select [other] and $ as well as comma so it may also be useful for your parser to allow '$ as comma'

    $002D1AB8$005A2BF2

    That imports into columns 2 and 3, as $ clones ,
    ie the hex char is allowed to displace a comma or space.

  • cgraceycgracey Posts: 14,151

    @jmg said:

    @cgracey said:
    Would anyone mind if I got rid of the commas in DEBUG outputs? They are sometimes good to look at, but just take more time to transmit.

    You mean make them optional ? Yes, that's a good idea. Anything that can shorten the character strings all helps, as in many cases those can feed straight into a USB buffer, and it all reduces the P2 time impact.

    Can I also suggest making hex-strings sticky in some way, so you do not need to send a HEX char with every number.
    Maybe if the command has a suffix $, then all chars following are taken as hex ?

    Addit:
    As a use example, in the past I've captured space or comma delimited hex strings, and pasted into a spreadsheet, then you can use HEX2DEC() to process those fields.
    Excel can import
    ,002D1AB8,005A2BF2
    or
    002D1AB8 005A2BF2

    Excel can even import this, if I select [other] and $ as well as comma so it may also be useful for your parser to allow '$ as comma'

    $002D1AB8$005A2BF2

    That imports into columns 2 and 3, as $ clones ,
    ie the hex char is allowed to displace a comma or space.

    That's great that commas are not required. I am going to investigate this more.

  • evanhevanh Posts: 15,915
    edited 2021-06-03 01:31

    Chip,
    Do you have any opinions/ideas on making indirection a syntax feature of Pasm? Similar idea to the AUGx instructions I'd imagine. The more coding I do the more I keep using ALTx instructions for small table/buffer work in cogRAM.

    Example suggestions:

            altd    regaddr, #0
            add 0-0, #immediate
    'becomes
            add [regaddr], #immediate
    
            alts    regaddr, #0
            add register, 0-0
    'becomes
            add register, [regaddr]
    
            altd    regindex, #base
            add 0-0, #immediate
    'becomes
            add [#base, regindex], #immediate
    
            alts    regindex, #base
            add register, 0-0
    'becomes
            add register, [#base, regindex]
    
            altsn   nibindex, #base
            setnib  register
    'becomes
            setnib  [#base, nibindex], register
    
            altgn   nibaddr, #0
            getnib  register
    'becomes
            getnib  register, [nibaddr]
    

    It would involve a change to existing hubRAM load/store syntax. Eg:

            wrlong  register, hubaddr
    'becomes
            wrlong  register, [hubaddr]
    

    and provides the consistency for this:

            altd    regaddr, #0
            wrlong  0-0, hubaddr
    'becomes
            wrlong  [regaddr], [hubaddr]
    
  • Chip,
    Is it possible to make a compiler switch to suppress the underscores „_“ in the number output.

    Or to make it simple.
    Debug(sdec(x)) prints x = 1_234
    and
    Debug(sdec_(x)) prints 1234 without the underscore.

    The underscore is good for human reading the debug output, but standard software can not read such numbers and work with it.

  • cgraceycgracey Posts: 14,151

    @evanh said:
    Chip,
    Do you have any opinions/ideas on making indirection a syntax feature of Pasm? Similar idea to the AUGx instructions I'd imagine. The more coding I do the more I keep using ALTx instructions for small table/buffer work in cogRAM.

    Example suggestions:

          altd    regaddr, #0
          add 0-0, #immediate
    'becomes
          add [regaddr], #immediate
    
          alts    regaddr, #0
          add register, 0-0
    'becomes
          add register, [regaddr]
    
          altd    regindex, #base
          add 0-0, #immediate
    'becomes
          add [#base, regindex], #immediate
    
          alts    regindex, #base
          add register, 0-0
    'becomes
          add register, [#base, regindex]
    
          altsn   nibindex, #base
          setnib  register
    'becomes
          setnib  [#base, nibindex], register
    
          altgn   nibaddr, #0
          getnib  register
    'becomes
          getnib  register, [nibaddr]
    

    It would involve a change to existing hubRAM load/store syntax. Eg:

          wrlong  register, hubaddr
    'becomes
          wrlong  register, [hubaddr]
    

    and provides the consistency for this:

          altd    regaddr, #0
          wrlong  0-0, hubaddr
    'becomes
          wrlong  [regaddr], [hubaddr]
    

    I need to look into this. There may be many rules and subtle exceptions to handle.

  • cgraceycgracey Posts: 14,151

    @wummi said:
    Chip,
    Is it possible to make a compiler switch to suppress the underscores „_“ in the number output.

    Or to make it simple.
    Debug(sdec(x)) prints x = 1_234
    and
    Debug(sdec_(x)) prints 1234 without the underscore.

    The underscore is good for human reading the debug output, but standard software can not read such numbers and work with it.

    I will look into this, too.

  • TonyB_TonyB_ Posts: 2,178
    edited 2021-06-04 12:32

    @evanh said:
    Chip,
    Do you have any opinions/ideas on making indirection a syntax feature of Pasm? Similar idea to the AUGx instructions I'd imagine. The more coding I do the more I keep using ALTx instructions for small table/buffer work in cogRAM.

    Example suggestions:

          altsn   nibindex, #base
          setnib  register
    'becomes
          setnib  [#base, nibindex], register
    

    It would involve a change to existing hubRAM load/store syntax. Eg:

          wrlong  register, hubaddr
    'becomes
          wrlong  register, [hubaddr]
    

    Register indirection is clunky at the moment and could and should be simpler. The main issue I have with ALTxx is that D is the index (reg only) and S is the base, whereas base first followed by index is more intuitive.

            altgn   nindex,#nbase
            getnib  bindex
            altsb   bindex,#bbase
            setbyte data
    '
    'becomes
    '
            getnib  bindex,[#nbase+nindex]
            setbyte [#bbase+bindex],data
    '
    '[base+index] not [base,index]
    'to show addition is involved
    

    It would be mistake to add square brackets to WRxxxx when there is no redirection.

  • evanhevanh Posts: 15,915
    edited 2021-06-04 12:50

    @TonyB_ said:
    It would be mistake to add square brackets to WRxxxx when there is no redirection.

    They accept a memory address, rather than data. If an immediate is encoded, it is a hubRAM address to get data from or write data to. If a register is encoded then the requisite hubRAM address is fetched from that register before performing the hubRAM access. That is indirection. Which makes all the hubRAM load/store instructions indirect.

  • evanhevanh Posts: 15,915
    edited 2021-06-04 13:14

    To be fair, in any architecture, only the register set can be direct addressed.

  • @evanh said:

    @TonyB_ said:
    It would be mistake to add square brackets to WRxxxx when there is no redirection.

    They accept a memory address, rather than data. If an immediate is encoded, it is a hubRAM address to get data from or write data to. If a register is encoded then the requisite hubRAM address is fetched from that register before performing the hubRAM access. That is indirection. Which makes all the hubRAM load/store instructions indirect.

    OK, it would be mistake to add square brackets to WRxxxx when there is no ALTxx involved.

  • evanhevanh Posts: 15,915

    That's a good way to view it. I doubted Chip was entertaining that part of the suggestions anyway since it would break backwards compatibility for just cosmetics.

  • A minor bug in Propeller Tool 2.5.3:
    The debug output (text teminal) window is not refreshed when re-sized. When moving the window around by dragging the title bar the text contents stay there but if the window is re-sized only a blank black area is left.

    Improvement request: It would be nice if mark and copy would work on the text for archiving/logging or documentation purposes.

Sign In or Register to comment.