Shop OBEX P1 Docs P2 Docs Learn Events
P2 JMP/CALL addresses to COG/LUT/HUB - Page 3 — Parallax Forums

P2 JMP/CALL addresses to COG/LUT/HUB

13»

Comments

  • Cluso99Cluso99 Posts: 18,066
    I had forgotten about ORGF. I fill with longs using a variable size based on $.

    Yes, we’re just wanting to suppress the error, but the current compilers might not have the ability to continue.

    Could we have a FITH for testing the current hub address?

    One thing I’ve noticed over the past week is that there are some traps for making code executable as both hubexec AND cogexec. Jump and call and the DJNZ and variations - relative addressing doesn’t seem to work for both cog and hub - it’s an either or case. I didn’t look deeply, but it’s possible the relative addressing is in bytes for hub and longs for cog.
    This leads me to ponder, is it useful to be able to have hub code compiled for a different hub address. BTW, I’m sure Eric will be ducking for cover about now! We used to compile relocatable code and then link it to its final address.
  • exactly

    And in a COG we do not need it there the existing ORG and ORGF are fine.

    Mike
  • msrobotsmsrobots Posts: 3,701
    edited 2019-08-12 00:02
    completely unrelated - thinking over @JonnyMac's last project, we need a new SECtion for the define ifdef and stuff like that, maybe -e or other directives.

    So a spin program would start with
    DEF
    ….
    CON
    ...
    

    Just saying...

    Mike
  • ersmithersmith Posts: 5,900
    edited 2019-08-12 00:32
    Cluso99 wrote: »
    This leads me to ponder, is it useful to be able to have hub code compiled for a different hub address. BTW, I’m sure Eric will be ducking for cover about now! We used to compile relocatable code and then link it to its final address.

    Well, fastspin does have -H and -E options for setting the base address of the executable code (so you can compile it to run at any fixed address). You could use that now for overlays. @msrobots used those switches for getting fastspin compiled code to work with TAQOZ.

    Truly relocatable code would be very useful, but that's a bit more work in the compiler (if you're just writing PASM you can already achieve this, of course :) ).

  • cgraceycgracey Posts: 14,133
    You could just type:

    ORGH $ < $400 ? $400 : $
  • cgracey wrote: »
    You could just type:

    ORGH $ < $400 ? $400 : $

    Wow Chip!
    You've been hiding that little gem from us.
    That "Verilog" style condition test works great!
    That changes my whole thinking on P2 assembler. :)
  • Conditional compile ,neat!
    		drvh	#zzz == 1 ? yyy==1? 24:27 : yyy == 1? 25 : 26
    
    
  • ... and it seems to have been in there since P2-Hot (oct 2013), at least

    Anything else you're not telling us about Pnut, Chip? : )
  • cgraceycgracey Posts: 14,133
    Tubular wrote: »
    ... and it seems to have been in there since P2-Hot (oct 2013), at least

    Anything else you're not telling us about Pnut, Chip? : )

    I don't think so. I just remembered that ternary operator.
  • TubularTubular Posts: 4,620
    edited 2019-08-12 05:44
    '*** Pnut for P2-Hot version - October 2013
    
    
    'test code - first case (yyy false)
    
     yyy = 0
     ytest = yyy ? 8 : 9
    
    
    'map output
    
    TYPE: 4B   VALUE: 00000000   NAME: YYY
    TYPE: 4B   VALUE: 00000009   NAME: YTEST
    
    OBJ bytes:       0
    
    _CLKMODE: 00
    _CLKFREQ: 00B71B00
    
    
    
    'test code - second case (yyy true)
    
     yyy = 1
     ytest = yyy ? 8 : 9
    
    ' map output
    
    TYPE: 4B   VALUE: 00000001   NAME: YYY
    TYPE: 4B   VALUE: 00000008   NAME: YTEST
    
    OBJ bytes:       0
    
    _CLKMODE: 00
    _CLKFREQ: 00B71B00
    
    
  • cgraceycgracey Posts: 14,133
    Tubular wrote: »
    '*** Pnut for P2-Hot version - October 2013
    
    
    'test code - first case (yyy false)
    
     yyy = 0
     ytest = yyy ? 8 : 9
    
    
    'map output
    
    TYPE: 4B   VALUE: 00000000   NAME: YYY
    TYPE: 4B   VALUE: 00000009   NAME: YTEST
    
    OBJ bytes:       0
    
    _CLKMODE: 00
    _CLKFREQ: 00B71B00
    
    
    
    'test code - second case (yyy true)
    
     yyy = 1
     ytest = yyy ? 8 : 9
    
    ' map output
    
    TYPE: 4B   VALUE: 00000001   NAME: YYY
    TYPE: 4B   VALUE: 00000008   NAME: YTEST
    
    OBJ bytes:       0
    
    _CLKMODE: 00
    _CLKFREQ: 00B71B00
    
    
    Tubular wrote: »
    '*** Pnut for P2-Hot version - October 2013
    
    
    'test code - first case (yyy false)
    
     yyy = 0
     ytest = yyy ? 8 : 9
    
    
    'map output
    
    TYPE: 4B   VALUE: 00000000   NAME: YYY
    TYPE: 4B   VALUE: 00000009   NAME: YTEST
    
    OBJ bytes:       0
    
    _CLKMODE: 00
    _CLKFREQ: 00B71B00
    
    
    
    'test code - second case (yyy true)
    
     yyy = 1
     ytest = yyy ? 8 : 9
    
    ' map output
    
    TYPE: 4B   VALUE: 00000001   NAME: YYY
    TYPE: 4B   VALUE: 00000008   NAME: YTEST
    
    OBJ bytes:       0
    
    _CLKMODE: 00
    _CLKFREQ: 00B71B00
    
    

    Man, maybe I already finished Spin2, but I haven't remembered, yet.
  • cgraceycgracey Posts: 14,133
    Cluso99 wrote: »
    I...One thing I’ve noticed over the past week is that there are some traps for making code executable as both hubexec AND cogexec. Jump and call and the DJNZ and variations - relative addressing doesn’t seem to work for both cog and hub - it’s an either or case. I didn’t look deeply, but it’s possible the relative addressing is in bytes for hub and longs for cog.

    Relative-constant branches are encoded the same for cog and hub code.

    I can't remember at the moment if the same is true for absolute-constant branches. Anyone know?
  • Cluso99Cluso99 Posts: 18,066
    Thanks Chip. I thought relative should have worked so maybe I had absolute coding, or another bug. I'll check it out later.

    Absolutes would be different address results though, depending on whether the code is in cog or hub space.
    So these wouldn't work for the same code designed to run in both spaces.

    Those hubexec time comparisons with cog are great news. No 4x penalty for lmm mode anymore :smiley:
  • cgracey wrote: »
    You could just type:

    ORGH $ < $400 ? $400 : $

    In fastspin that has to be:
    ORGH ($ < $400) ? $400 : $
    
    due to ambiguity around the "?" operator (fastspin still supports Spin1). But it otherwise works fine, so I guess we can shelve this discussion :).

    Thanks for remembering this Chip!
  • Cluso99Cluso99 Posts: 18,066
    Wow, what a nifty feature :smiley:
  • RaymanRayman Posts: 13,805
    So, we can already do this using a C style conditional operator that PNUT and FastSpin already have...

    Interesting...
Sign In or Register to comment.