Question about hubexec code alignment
Christof Eb.
Posts: 1,195
Hi,
sorry that I am asking once again. I could not find an explicit answer. It is said that all hub accesses are byte orientated.
Is it true, that it is not necessary to have code long-alinged for hubexec? Codes can start at any byte?
(((The background is, that Peter in TAQOZ used CALLD PTRA,#address to switch back from assembler code to 16bit wordcode, which is then fetched by rdword x,PTRA++ . For some reason this only works sometimes. Edit: and clearing Z and C does not help.)))
Thank you!
Christof
Comments
This is true. But the timing is affected.
Thank you very much!
Misalignment has small effect on timing, minimal really. FIFO reloading and hub word or long accesses take one more cycle but instructions take same time as cog / LUT exec if they don't involve hub RAM.
CALLD is one instruction to be very careful with how it gets used. It relies on those registers for remembering the return address at a later place in time and code. They can be used in neat ways, eg: the interrupt ISRs are called via a wired version of that instruction.
But write that register in the interim and you've got an imminent crash on your hands. The "switch back from assembler code" will rely on a prior setup of PTRA which cannot be altered by the remainder of the assembly code itself.
I must have forgotten about that…
Guess that means FlexProp hubexec code could be slightly slower for loops and jumps if not long aligned. It probably is long aligned though, I’m assuming…