Using Port B “I/O Pins” to Synchronize Multi-cog Events

AwesomeCronkAwesomeCronk Posts: 542
edited 2019-03-30 - 11:31:23 in Propeller 1
Just think of the memory you could save and the precision synchronization you might achieve!
One cog:
Dirb[0] := %1
Outb[0] := %1

Other cog:
Waitpeq(forgot my syntax)

Basically one cog sets a nonexistent pin high and the other waits for it to get there and takes off!
That's not an explosion! That's an unscheduled rapid disassembly!

Comments

  • I think it doesn't work that way - Port B's registers aren't hooked up to anything, IIRC
  • Aww. Man I thought I could start a revolution with this.😋
    That's not an explosion! That's an unscheduled rapid disassembly!
  • Discussed many years ago :(
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,263
    edited 2019-03-30 - 18:29:22
    The port B registers are just shadow registers exclusive to each cog, without any kind of interconnection between cogs. They're still usable as general-purpose registers, though.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • BTW this feature is in the Propeller 2.
    It has the COGATN and WAITATN instructions.
    They wok great! :)
    Melbourne, Australia
  • Unfortunately there are no HIDDEN I/O lines on P8X32A.
    If any, C flag is to be set (or cleared) for monitoring INB (INA, resp.) by WAITPxx.
  • msrobotsmsrobots Posts: 2,473
    edited 2019-03-31 - 05:25:47
    yisiguro wrote: »
    Unfortunately there are no HIDDEN I/O lines on P8X32A.
    If any, C flag is to be set (or cleared) for monitoring INB (INA, resp.) by WAITPxx.

    And who should change inb while waiting on it? No sadly as you stated inb/outb/dirb where never implemented.

    But in spin you can use them as repositories and for bit converting.


    Something like
       dirb[0..3] := a
       a := dirb[3..0]
    

    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • There are other tricks with the shadow registers. You see, those special registers are also cog ram. I put a debug routine in there snd it can sinle step programs including spin. IIRC its in obex as well as a P1 thread.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • My mother tongue is not English, so I might make you guys confused a little.
    But those tricks are interesting. Thanks.
  • AwesomeCronkAwesomeCronk Posts: 542
    edited 2019-03-31 - 11:08:56
    This is cool! @Cluso99, do you have a link to the obex site where that code is?

    @msrobots, this bit converting idea could be used to make string encrypters! Or to locate a single bit among a string or large number value!
    That's not an explosion! That's an unscheduled rapid disassembly!
  • @yisiguro,

    first of all welcome to the forum. Second, don't worry your English is quite fine as far I am concerned.

    It looks like you already went deep into the P1 but have just 14 posts, so be aware that this forum is addictive.

    At least I am addicted since a decade and do not regret it. I have learned a lot here and discovered whole new worlds of things I am interested in and am able to do with a Propeller and some help from my Friends Forum Members.

    I am programming the propeller (for fun) since a decade, have tons of useless (or not commercial usable) projects and still find out tips and tricks for the P1. It is a wonderful little beast.

    @AwesomeCronk,

    yes, it is not my idea, I stole it somewhere, and it is actually not a good practice to do so, even if Parallax never build the P1B with two ports, the open source FPGA versions of the P1 do/can support port B.

    And the P1 interpreter for the P2 does also support port B.

    But if intended to just run on a standard P1 then, yes Port B is open for grab and do bit manipulation with that nice [x..y] syntax.

    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • This is cool! @Cluso99, do you have a link to the obex site where that code is?

    "Spin and Pasm Debugger - Zero footprint"
    http://obex.parallax.com/object/567

    Really cool.
  • @msrobots
    Thanks for such an encouragement (isn't it, right?). Yes, I seem to be almost addicted. I'll take your advice to heart. Thanks again.
  • Now begs a landslide question. Can a compiler be hidden in the shadow register?
    That's not an explosion! That's an unscheduled rapid disassembly!
  • msrobotsmsrobots Posts: 2,473
    edited 2019-04-02 - 22:59:48
    Now begs a landslide question. Can a compiler be hidden in the shadow register?

    Oh no, it is a wonder that @Cluso99 could even fit a debugger in there, we are talking about a couple of longs usable for code execution at the end of the COG ram, normally used as control registers.

    Take ina for example.

    If you write to ina the value is written to the COG ram register.
    If you read from ina the value comes from the port, not from the COG ram register.
    That is while it is called a shadow register.

    But if you execute code from that location the COG does not fetch the code to execute from the port, but from the register in COG ram.

    Quit tricky,

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
Sign In or Register to comment.