Shop OBEX P1 Docs P2 Docs Learn Events
HUBEXEC: TIPS & TRAPS - All about the restrictions of running code from hub ram..... — Parallax Forums

HUBEXEC: TIPS & TRAPS - All about the restrictions of running code from hub ram.....

Cluso99Cluso99 Posts: 18,069
edited 2014-03-26 23:59 in Propeller 2
I thought we should have a thread devoted to what the restrictions are for code running from hub ram (known as HUBEXEC mode).

This post will become a summary and links to the post about it.

1. Self-modifying code is not possible for hub code (SETD/SETS/SETINST/SETCOND cannot modify hub code).
http://forums.parallax.com/showthread.php/154940-HUBEX-TIPS-amp-TRAPS-All-about-the-restrictions-of-running-code-from-hub-ram.....?p=1253422&viewfull=1#post1253422

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2014-03-26 19:52
    1. Self-modifying code is not possible for hub code (SETD/SETS/SETINST/SETCOND cannot modify hub code).

    While there may be more complex ways to achieve this, it is more than likely to fail.
    It is also possible to use HUBEX code from multiple cogs/tasks/threads concurrently (typically known as re-entrant code) and this would be broken if self-modifying code were used!
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-03-26 20:11
    2. Be careful about referring to orgh hub labels and not org cog labels

    p.s.

    p2 docs call it "hub execution", on the threads we've shortened it to "hub exec" and even "hubexec"

    I don't like "hubex" as it does not clearly imply execution.
  • cgraceycgracey Posts: 14,133
    edited 2014-03-26 22:11
    LOCBASE/LOCBYTE/LOCWORD/LOCLONG/LOCINST D,@ and LOCPTRA/LOCPTRB @ are best used by code executing from the hub, since relativity is maintained. When these instructions are executed from the cog, the absolute address of the @ must be known in order to properly compute PC+@, since PC is now (absolute) $000.$1FF. Also, the @ must always refer to hub memory space (ORGH) and not cog space (ORG).
  • potatoheadpotatohead Posts: 10,254
    edited 2014-03-26 22:34
    I like HUBEXEC too. I've typed it both ways, and always think of FEDEX...
  • SapiehaSapieha Posts: 2,964
    edited 2014-03-26 23:59
    Hi.

    For real Addresses use for ORGH.

    Real Address divided by 4

    orgh $E00 /4 '$380 = 18-bit load address $E00
    orgh $1000 /4 'some hub code at $1000


    Else it will not be address that You maybe was thinking to use
Sign In or Register to comment.