Word array into a long array
Dave Matthews
Posts: 93
I would like to take a word size array and feed it into a long size array.
I would like the wordtest[0] element to become the longtest[0] element ... wordtest[1] to become longtest[1],... and so on.
Dave
I would like the wordtest[0] element to become the longtest[0] element ... wordtest[1] to become longtest[1],... and so on.
Dave
Comments
This assumes that you do not want the upper word of the long array to be modified by the copy. If you don't want to keep the original high word contents in the long array, you can do this with a simple loop, or modify the above code like this
The reason for pointers is that the method will work with any arrays you have.
I do want the upper words to be zeroed so the simple loop is for me (didn't see the other loop?).
I am grateful that you did not have to refer me to a spin language command that would do the same thing, I always try to check everything and OBEX before posting a question here.
At any rate your description is very clear and I am very grateful.
Dave
Boom! Done. Now, this is fine if you only have to two arrays. If there are more then you can use the second snippet above and pass pointers.
... for example, if you had 10 elements to move. BTW... names are resolved to pointers internally, so getting comfortable with them is a useful way to create more flexible code.
This uses a local variable as an index. I know it seems odd to have the post-increment on the left side but this is where it belongs; we don't want to increment N until the value has been moved from one array to another. Note, too, that he's actually using the result variable (this is noted by the use of : after the method name); this variable is always set to zero on entering a method.
Dave