Sunday 15 May 2011

assembly - Indirect Addressing and Arrays -



assembly - Indirect Addressing and Arrays -

class="snippet-code-html lang-html prettyprint-override">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 word in order used in stack ascii representing numbers in 2 bytes(1 byte each digit) msg db "the smallest value in matrix is:",10 msgl equ $-msg section .bss smallval resw 2 section .text global _start _start: mov edi, 0 ;will used in order indicate when end of matrix has been reached mov esi,0 ; used indicate when end of row has been reached mov ecx, [matrix + edi +esi*2]

i working on programme takes matrix , tries find smallest value in matrix. new programming,only having started programming java 4 months , learning asm well. question regarding indirect addressing. next statement [eax + edx](given arbitrary value stored in eax , edx). according website found finds effective address, not sure means.

thanks

thanks quick responses. problem lies in how indirect addressing works registers. have attached code snippet top of thread. problem lies on line mov ecx,[matrix+edi+esi*2]. not sure line does.

the line of code

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

fetches element array wrong! since array has been defined words have utilize cx in stead of ecx.

to farther understand addressing mode. edi controls outer loop , evolve in steps of 10 0 40 (stopping @ 50) esi controls inner loop , cycle 0 4 (stopping @ 5)

assembly x86 nasm

No comments:

Post a Comment