A very basic question about Arrays in Pasm (2nd edit)
b.p.m.
Posts: 59
hi everyone,
i've been searching the assembly tutorials, the forum and any
program that i've downloaded for a simple example of array
usage in pasm.
i have two small arrays as follows;
disp long $3f,$06,$5b,$4f,$66,$6d,$7d,$07,$7f,$6f
disp_g long $0e,$0d,$0b,$07
how do i go about using an offset register in pasm to recover
say " disp[noparse][[/noparse]pntr]" (spin syntax) where pntr is say 4 returning
"$66" ? i know this is simple and basic but until i find out how
to do it, i'm stuck.
do i use the following:
mov pntr,#4
mov temp,@disp
add temp,pntr
mov result,@temp
much thanks in advance,
blake
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Can't sleep, clown will eat me."
Bart Simpson
Post Edited (b.p.m.) : 6/5/2009 3:57:42 AM GMT
i've been searching the assembly tutorials, the forum and any
program that i've downloaded for a simple example of array
usage in pasm.
i have two small arrays as follows;
disp long $3f,$06,$5b,$4f,$66,$6d,$7d,$07,$7f,$6f
disp_g long $0e,$0d,$0b,$07
how do i go about using an offset register in pasm to recover
say " disp[noparse][[/noparse]pntr]" (spin syntax) where pntr is say 4 returning
"$66" ? i know this is simple and basic but until i find out how
to do it, i'm stuck.
do i use the following:
mov pntr,#4
mov temp,@disp
add temp,pntr
mov result,@temp
much thanks in advance,
blake
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Can't sleep, clown will eat me."
Bart Simpson
Post Edited (b.p.m.) : 6/5/2009 3:57:42 AM GMT
Comments
Here's an example of how to do the self-modifying code that Maji02 mentioned, together with the comment in my code that explains it. Hope this helps,
Dave
thanks for advice on using pointers. i didn't realize
that indirect addressing wasn't supported in a
otherwise powerful assembly. thanks David for
your example code; it's just what i was needing.
by the way, does anyone know any good tutorials
on Prop assembly; i've read de Silva's and potatohead's
tutorials,(which were good) but i need more in depth
information. like the aforementioned problem i am
getting stuck simply from lack of knowledge.
thanks again
blake
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Can't sleep, clown will eat me."
Bart Simpson
(I was in a hurry this morning, otherwise I'd have posted some code by myself.)
I would not call the self-modifying code a workaround. It was a design decision to do indirection in that way! Indirection as used on other CPUs adds complexity to the execution unit of the CPU -> so it needs additional real estate on the die -> die would be to big for DIP package -> we would not have a hobbyist-friendly propeller ;o) And/Or it has impact on the pipeline.
I have the feeling that the Hydra book would be a good read. But maybe someone who ows one can acknowledge this, because I don't have one yet. Besides the mentioned tutorials I don't know of any additional teaching papers. Did you see the Assembly for beginners link in the sticky?
Simply ask your questions here.