arrays in Assembly?
mike56
Posts: 22
How do I fill an array in Cog memory using a loop in Parallax Assembly?
If I wanted to read from main memory, I could pass cognew(@myfunc,@myarray)
······· ·mov myarrayptr,par
········ mov Counter, #50
loop·· wrlong myarrayptr, mystuff
········ add myarrayptr,#1
········ djnz Counter,#loop
But in Cog memory, I can only move into a register not an address.
Basically, I want to do:
······· mov arrayptr,#myarray
······· mov Counter,#50
loop·· mov @arrayptr, mystuff
········add arrayptr,#1
······· djnz Counter,#loop
How do I do the "mov @arrayptr,mystuff" in assembly?
If I wanted to read from main memory, I could pass cognew(@myfunc,@myarray)
······· ·mov myarrayptr,par
········ mov Counter, #50
loop·· wrlong myarrayptr, mystuff
········ add myarrayptr,#1
········ djnz Counter,#loop
But in Cog memory, I can only move into a register not an address.
Basically, I want to do:
······· mov arrayptr,#myarray
······· mov Counter,#50
loop·· mov @arrayptr, mystuff
········add arrayptr,#1
······· djnz Counter,#loop
How do I do the "mov @arrayptr,mystuff" in assembly?
Comments
http://ucontroller.com/machinelanguage.pdf
There is a section in there on doing exactly what you want to do. Basically, you have to use the "movs" and "movd" instructions to modify the mov instruction that accesses your array.