Reputation: 33946
It seems I can't get enough good documentation on assembly, at least none that's intelligible.
Could someone post a simple example on how to declare an array and a matrix on assembly? And possibly how to modify items in it. It will be of great help for me and probably to many others.
Upvotes: 4
Views: 22451
Reputation: 33946
I solved this using an example provided by the emulator.
Basically matrixes in assembly are declared the same as regular variables, a 2x2 matrix for example is declared like this:
matrix db ?,?,?,? ; Obviously `?` can be replaced by any value
or
matrix db dup('?')
Then the user decides where he considers a "row" ends and another starts. For example if we have a variable with bytes 1,2,3,4 the user may consider that 1,2 are one row and 3,4 are another.
This is how you point to an item in the matrix:
mov bx,0
lea si,matrix
mov matriz[si][bx],0 ; [si][bx] holds the value of the first cell
Now if each row holds 2 items, one should just do this to go to the second row:
add bx,2
mov matriz[si][bx],1 ; Now [si][bx] points to cell 0x1
Upvotes: 2
Reputation: 5884
Emu8086 syntax is almost the same as the MASM syntax, so to declare an uninitialized array that will hold 3 bytes:
arr1 db 3 dup (?)
Upvotes: 3