HUBEXEC: TIPS & TRAPS - All about the restrictions of running code from hub ram.....
Cluso99
Posts: 18,069
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
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
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!
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.
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