Hello everyone, I have been trying to figure out the best way to work with arrays in assembly, and I have been running into some problems. I would like to add a column to this 2D array, but I am not sure of the best way to do it. Would I have to copy the original data to a separate area of memory, or is there an easier way, simply by counting the original amount of columns per row, and then adding a 0 onto the end of every line?
Code:
To something like this:
Code:
Any help is much appreciated!
(yes, this is really not how the bytes will appear in memory, it is just easier for me to think this way.)
Code:
Data:
.db 12,8 ;Columns,Rows
.db 3,2,2,2,2,2,2,2,2,2,2,4
.db 1,0,0,0,0,0,0,0,0,0,0,1
.db 1,0,3,2,2,2,4,0,3,2,4,1
.db 1,0,1,0,0,0,1,0,1,0,1,1
.db 1,0,1,0,0,0,1,0,1,0,1,1
.db 1,0,5,2,2,2,6,0,5,2,6,1
.db 1,0,0,0,0,0,0,0,0,0,0,1
.db 5,2,2,2,2,2,2,2,2,2,2,6
To something like this:
Code:
Data:
.db 13,8 ;Columns,Rows
.db 3,2,2,2,2,2,2,2,2,2,2,4,0
.db 1,0,0,0,0,0,0,0,0,0,0,1,0
.db 1,0,3,2,2,2,4,0,3,2,4,1,0
.db 1,0,1,0,0,0,1,0,1,0,1,1,0
.db 1,0,1,0,0,0,1,0,1,0,1,1,0
.db 1,0,5,2,2,2,6,0,5,2,6,1,0
.db 1,0,0,0,0,0,0,0,0,0,0,1,0
.db 5,2,2,2,2,2,2,2,2,2,2,6,0
Any help is much appreciated!
(yes, this is really not how the bytes will appear in memory, it is just easier for me to think this way.)