Beginner Assembly Arrays problem
bikejunky
Posts: 33
Im trying to teach myself Propeller Assembly. I bought Harpits book, it has helped get me moving a little.
Ive been converting some of the example programs from the PE kit labs to assembly. Mostly just flashing led patterns from the Parallax Serial Terminal. Now I would like to put an array/table in a cog light the leds and display the pattern on the PST. I am using a Quickstart board. (I hacked up Chuck McManis code from a post on MOVS, MOVD, MOVI and MOV). It is below. I would appreciate any help and I am sure I will be asking more questions on this program even when it works.
Ive been converting some of the example programs from the PE kit labs to assembly. Mostly just flashing led patterns from the Parallax Serial Terminal. Now I would like to put an array/table in a cog light the leds and display the pattern on the PST. I am using a Quickstart board. (I hacked up Chuck McManis code from a post on MOVS, MOVD, MOVI and MOV). It is below. I would appreciate any help and I am sure I will be asking more questions on this program even when it works.
con _clkmode = xtal1 +pll16x _xinfreq = 5000000 Obj pst:"Parallax Serial Terminal" var long alongV long cog long temp Pub Main ''array in assembly in cog Parallax Serial Terminal pst.Start(115_200) ' might have to be slower for raspberry pi pst.Char(pst#CS) 'Clear Screen cog:=cognew(@myArray,@alongV) repeat pst.Bin(alongV,8) pst.Str(String(pst#NL)) DAT org 0 myArray mov hubaddress,par entry MOV temp3, #Index ' Load the address of Index into temp3 MOVS :loop, temp3 ' Modify the instruction at label :loop to point at Index (Note 1) MOV temp1, #32 ' Create a 32 iteration loop :loop MOV temp2, Index ' Load a value into Temp2 MOV temp3, :loop ' Load the instruction from :loop into temp3 ADD temp3, #1 'Now temp3 has the instruction but its pointer has been incremented MOVS :loop, temp3 'Now the instruction at :loop has been modified to load the next long (Note 2) wrlong temp2,hubaddress nop mov myTemp,temp2 '... do something with temp2 ... ' shl myTemp,#16 ' your program uses the value from the array mov dira, myTemp mov outa, myTemp call #pause mov myTemp,#0 DJNZ temp1, :loop ' Now loop back to :loop and get the next value pause mov del_time, delay :mloop djnz del_time,#:mloop pause_ret ret hubaddress res 1 myTemp res 1 del_time res 1 delay long 10_000_000 temp1 LONG 0 temp2 LONG 0 temp3 LONG 0 Index LONG %1111 ' Value of array at [0] LONG %1110 ' ... at LONG %1101 long %1100 long %1011 long %1010 long %1001 long %1000 long %0111 long %0110 long %0101 long %0100 long %0011 long %0010 long %0001 long %0000 long %11111111 long %0000 long %0001 long %0010 long %0011 long %0100 long %0101 long %0110 long %0111 long %1000 long %1001 long %1010 long %1011 long %1100 long %1101 long %1110 long %1111 ' ... at '... repeated for 29 more values ... FIT ' Make sure everything fits
Comments
I suggest that you give your array a more meaningful name that Index. Remember that the address operator in PASM is # (versus @) in Spin. You might do something like this (note that this code is NOT complete)
If I may... have a look at this line from your program:
Note how the comment is a slap-in-the-face obvious? The instruction says what it's doing -- no need to put that in a comment. If you're going to add comments, they should explain in context, not spell out what we can plainly see, anyway.
Thanks, I think I'm on my way