How does this instruction work? in Beau's SPI_Asm (self modifying code)
For the life of me I can't work out what this instruction does.
The code is well documented except for this section where it is getting the parameters from hub ram via decoding the command long pointed to by par.
I understand that the loop is self modifying the destination section in the rdlong command to point to the next reserved arg location, but adding 512 to :arg has lost me.
I'm one of those guys that to modify code I need to understand the workings of the original code.
Will someone put me out of my misery please.
Another less pressing question is why the +2 in the following line
Sorry for the newbie questions.
Cheers,
Phil
add :arg,d0d0 is predefined to equal $200 or 512d. Why $200 ?
'' SPI Engine - main loop
'
loop rdlong t1,par wz ''wait for command
if_z jmp #loop
movd :arg,#arg0 ''get 5 arguments ; arg0 to arg4
mov t2,t1 '' │
mov t3,#5 ''───┘
:arg rdlong arg0,t2
add :arg,d0
add t2,#4
djnz t3,#:arg
mov address,t1 ''preserve address location for passing
''variables back to Spin language.
wrlong zero,par ''zero command to signify command received
ror t1,#16+2 ''lookup command address
add t1,#jumps
movs :table,t1
rol t1,#2
shl t1,#3
:table mov t2,0
shr t2,t1
and t2,#$FF
jmp t2 ''jump to command
jumps byte 0 ''0
byte SHIFTOUT_ ''1
byte SHIFTIN_ ''2
byte NotUsed_ ''3
NotUsed_ jmp #loop
The code is well documented except for this section where it is getting the parameters from hub ram via decoding the command long pointed to by par.
I understand that the loop is self modifying the destination section in the rdlong command to point to the next reserved arg location, but adding 512 to :arg has lost me.
I'm one of those guys that to modify code I need to understand the workings of the original code.
Will someone put me out of my misery please.
Another less pressing question is why the +2 in the following line
ror t1,#16+2 ''lookup command addressIn encoding the command we shifted left only 16 bits
Sorry for the newbie questions.
Cheers,
Phil

Comments
-Phil
Now that you point it out, it's just so simple. I just couldn't see it.
The only problem I have now is how long it will take this big red hand print on my forehead to go away.
Cheers,
Phil
It's easy to see now I know what I'm looking for.
On page 13 under the heading "Embedding Array Pointers" the same technique is used just with the " $200 " written a different way " 1 << 9".
Hope that helps someone else make the link in the future.
Cheers,
Phil
One more bit of the ASM puzzle solved.
Cheers,
Phil