Indirect Addressing and Arrays
section .data
matrix dw 1,2,3,4,5
dw 6,7,8,9,10
dw 11,12,13,14,15
dw 16,17,18,19,20
dw 21,22,23,24,25
;defined as word in order to be used in stack as well as ASCII representing numbers in 2 bytes(1 byte for each digit)
msg db "The smallest value in this matrix is:",10
msgL equ $-msg
section .bss
smallVal resw 2
section .text
global _start
_start:
mov edi, 0 ;will be used in order to indicate when end of matrix has been reached
mov esi,0 ; will be used to indicate when end of row has been reached
mov ecx, [matrix + edi +esi*2]
The line of code
mov ecx, [matrix + edi +esi*2]
fetches an element from the array but it is wrong! Since the array has been defined as words you have to use CX in stead of ECX.
To further understand the addressing mode.
EDI controls the outer loop and will evolve in steps of 10 from 0 to 40 (stopping at 50)
ESI controls the inner loop and will cycle from 0 to 4 (stopping at 5)
上一篇: 如何在另一个函数中获取Delphi代码标签的地址?
下一篇: 间接寻址和数组