PASM command "WRLONG INA, HubAddr" won't work?
MJHanagan
Posts: 189
I discovered what seems to me to be an oddity in PASM. I am trying to understand the relationship of registers DIRA, OUTA and INA in a cog compared with other running cogs as well as in cog0. I tried the following code:
The DIRA and OUTA registers were correctly written to the main hub memory but the INA result was all zeros.
I then tried this bit of code:
And it worked fine.
Any idea why the WRLONG INA, INaddr command failed?
CmdDone WRLONG DIRA, DIRaddr WRLONG OUTA, OUTaddr WRLONG INA, INaddr WRLONG DONE, CmdAddr 'Set command variable to zero to indicate done with last command. JMP #CmdWait 'Go back and wait for next command
The DIRA and OUTA registers were correctly written to the main hub memory but the INA result was all zeros.
I then tried this bit of code:
CmdDone WRLONG DIRA, DIRaddr WRLONG OUTA, OUTaddr mov Tmp, INA WRLONG Tmp, INaddr WRLONG DONE, CmdAddr 'Set command variable to zero to indicate done with last command. JMP #CmdWait 'Go back and wait for next command
And it worked fine.
Any idea why the WRLONG INA, INaddr command failed?
Comments
This should copy the pins to ina's shadow register. The wrlong then writes the shadow register contents to the hub.
-Phil
They must just be keeping with the structure rule that applies to the basic PASM command structure of: "command" "destination", "source" even though the WRBYTE, WRWORD and WRLONG commands treat the the first variable as read only. Even the Propeller Manual states that "The WR effect can not be used with WRLONG as that would change it to a RDLONG instruction.
Thank you for the explanation!
Want to guess "number" 1?
Incorrect passing of the PAR?
-Phil
Maybe
instead of
but not if you do something like Despite this being almost never useful... Perhaps # should have been assumed for numeric
constants, and @1 used for the above behaviour.
There are valid reasons to not have # in some jmp commands though .
There are other common errors to avoid.
1. Never put RES in the middle of code.
2. Never assume ORG N sets a global start address (it sets the src/addr reference offset).
3. Others: see Phil's Tricks & Traps document.
-Phil
Yes, the mov INA, INA followed by WRLONG INA, INaddr does work. So now I'm really confused. I though INA was read-only.
-Phil
It's probably too late to deal with => and =< or to swap -> (the one with the minus sign; that's a rotate) with ~> (the one with the rotary-looking tilde; that's a sign-extended shift) though. And I think the precedence rules should align more with those of other languages, although I like Spin's better.
-Phil
This is Phil??? I'll take it even with the caveat!
Happy New Year!
Happy New Year to you, and everyone else on the forum! 2014: the year of the P2!
-Phil