CALL and local variables of in-line PASRM2
ke4pjw
Posts: 1,155
Something is occurring that I simply do not understand with my inline PASM. When I CALL a routine in inline PASM, local variables previously setup are cleared upon RET from the routine.
Here is an example: The rx routine is within the inline PASM. The routine does not manipulate l_RX_RSR, but its value is $00000000 after RET from CALL. When I check the HUB values at rxptr, they are empty.
mov l_RX_RSR,##$FFFF call #rx WRWORD rxptr,l_RX_RSR
Is this expected?
Comments
You have D and S reversed in wrword -- this works.
I am an idiot. Bwhahahaha! Sorry. How embarrassing!
I've been caught out by that sort of thing lots. Switching between Spin and Pasm for the same routines usually trips me up. Sadly, most assemblers use a reverse notation for operand syntax. I blame Intel and M$ for that dominance.
Destination-on-the-right assembly syntax exists because otherwise the order for subtract/compare instructions would be confusing.
idle chat:
it's also funny that the most basic instruction "move" is actually "copy"
I assume you meant destination-on-the-left. Since SUB is the exception, it's a particularly poor reason. The real reason will be from formal maths. Reverse notation is the norm there.
Actually, there's nothing wrong with saying subtract R1 from R2 with result in R2 ...
sub r1, r2
Or even result in r3 ...
sub r1, r2, r3