can any one suggest me how to create an array for 89c51? i want to create an array in the internal ram and move the contents of this array to a different location of internal ram. I am writing code in assembly language and want to continue with the same.
Unfortuneately internal RAM is an imprecise term in the 8051 architecture.
There is the directly accessible data space from 0x00 to 0x7F. This space contains the four register banks (0x00 to 0x1F) and the 128 addressable bits(0x20 to 0x2F). Then there is the indirectly accessible data space from 0x80 to 0xFF. Lastly there is data memory from 0x0000 to 0xFFFF. Most 8051 variants implement only a portion of this space.
The complication in the routine you want to write is knowing the boundaries of the two arrays. With three possible source addresses, three possible destinations that's nine different routines. This of course assumes that the arrays do not cross boundries or overlap each other.
Most assemblesr have a pseudo-operation like DB (Define Byte) for an array with intial values, or DS (Define Storage) for an array with no initial values.
my array size for simulation process i have reduced it to 3 bytes i am free to use any location so i would start from 0080h and use db & ds which solved my issue thanks
I'm glad to have been helpful.
An assembly language routine to move an array pointed at by R0 to an array pointed at by R1 for the number of bytes in R2 would look like
The routine I wrote only works for variables in internal RAM since that was what the original poster wanted. I assumed he could do the declarations from his previous post since he said he understood the use of db and ds pseudo operations, but thanks for the additional suggestions.
The routine for xdata to xdata is just a bit more complicated and less obvious. It also assumes there is only a single data pointer.