Arrays in ASM?
Javalin
Posts: 892
Hello All,
How do I do arrays in Propeller ASM?
I've declared:
··· ubxData················ res········ 50·
to store it.··Trying to get the address of the array using:
··· mov···· ubxDataPtr,@ubxData
results in "Source Register cannot exceed $1FF"
I guess thats not the way to do it?· I want to get the address of the beginning of the array into a counter, then increment it as I recieve data into it.
Im probably missing something simple!
Many thanks,
James
How do I do arrays in Propeller ASM?
I've declared:
··· ubxData················ res········ 50·
to store it.··Trying to get the address of the array using:
··· mov···· ubxDataPtr,@ubxData
results in "Source Register cannot exceed $1FF"
I guess thats not the way to do it?· I want to get the address of the beginning of the array into a counter, then increment it as I recieve data into it.
Im probably missing something simple!
Many thanks,
James
Comments
Why not read through my tutorial?
BTW: It should be
But that is just the beginning of the story....
Post Edited (deSilva) : 2/16/2008 12:28:36 PM GMT
Just reading deSilva's tutorial for that extra 20%...!
J
ubxData long/word/byte [noparse][[/noparse]amount of data]
Also note that you will need a variable in the cog to store the address of the array in
Javalin
-Phil
Still recommending reading it
I looked (I think at the right thread) after you said - but could'nt see an obvious ref. I assume its the Assembly06 or Assembly07 PDF's in the tutorial stickey thread?
J
Post Edited (Javalin) : 2/16/2008 6:55:33 PM GMT
-Phil
http://forums.parallax.com/showthread.php?p=668559
@Phil: Right!
Edit: done it again
Post Edited (stevenmess2004) : 2/16/2008 9:57:42 PM GMT
J
-Phil
How to I write to a COG based array?
Based on PhilPi's read code above...· For an example i'm trying to·write "1" in each·location and then read it back and sum.··From Phil's read example·I assume that I can swap the "add sum,0-0" to "add 0-0, #1" and change the movS to a movD as·I am·writing to not reading from.
However, as you've probably guess'd it doesn't work - it·returns·a sum total of "1".· Help?
thanks,
James
PS - deSilva - your EX07C would seem to have a typo on the last line - surely should read "X··· RES 20"???
(Updated for clarity)
Post Edited (Javalin) : 2/17/2008 8:30:52 PM GMT
I'll take the first stab then - I assume there is an answer though?
The first example has more instructions and uses a seperate ptr variable then spends time putting it back into ":add". The third example is the tidyest - uses the loop ":add" var and the ptr in the same instruction.
Marks out of ten?
James
Post Edited (Javalin) : 2/18/2008 9:09:00 AM GMT
(b) wrt the quizz that is Phil's matter
(a) Your example... You are a little bit incoherent... What is "SUM" which you say is "1"? As there is just a part of the program one has to giess.
You understand that you now always add to UBXDATA and to nothing else, as the "dest" of the ADD instruction is never changed again.... What you modify is the "source" part, so the "SUM" should be 2450 in the end...
I've updated the post - sorry about that.
James
See:
(a) You have to MOV the value in question
(b) So it is "dest" of MOV that has to be modified
(c) That can no longer be done by ADD ... #1 as this modifies "source" only
(d) So think of a way to add to the "dest" field. (Hint: there is NO special instruction for this!)
Regarding your quiz answer: you're right as far as it goes. But look at the last two programs and where the embedded pointer is incremented, with respect to the add instruction itself. The point of the quiz is to identify how these two programs sum the same array elements.
-Phil
Very clever. My first thought was, "that's not right", but of course it is. The comment on the :loop line isn't entirely complete though, but I guess that would have spoilt the fun of the quiz.
Many thanks for the help on this.· Got it working.
:-)
I'll post the full code tomorrow (for COG and HUB example)·when I get a chance (for those interested).
James
·
DeSilva noticed of course immediately that the comment on the :add1-line is misleading, but that's just by the way
No you have time to go back to Phil's quizz. He showed an "optimization" there. You already remarked
that the principle was to substitute a full memory cell by a 9-bit field of an instruction..
It something similar possible for this pre-setting of the array?
I re-looked at my code and I can set the inital address of #asmDataArray (new variable names in the posted example) with "movd :write1,#asmDataArray"·but I then cannot·add to·it without writing a counter variable to it using "movd :write1,#idxCount".·
The only other way would be using a shift instruction - but that seems messy...
In the interim i'll post these two examples - which work - but maybe optimizable....
(Debug_PC.spin and fullduplexserial.spin are needed for these to run as the output is to a serial terminal...)
Can I have another hint?
Thanks,
James
Post Edited (Javalin) : 2/20/2008 6:02:56 PM GMT