间接寻址和数组

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]

代码行

mov ecx, [matrix + edi +esi*2]

从数组中提取一个元素,但它是错误的! 由于数组已被定义为单词,所以您必须使用CX代替ECX。

进一步了解寻址模式。
EDI控制外部循环,并将以10为单位进行从0到40(停止在50)
ESI控制内部循环,并将循环从0到4(停在5)

链接地址: http://www.djcxy.com/p/89887.html

上一篇: Indirect Addressing and Arrays

下一篇: Why Delphi compiler does not inline assembly functions?