Dear Frank,
I am looking for Your help during all the the time after posting the query. Thanx mentor. I have changes my logic following your Row-Major matrix representation technique.. But I got NOW eerie results. For your conveniecnce I put my code here:
section .data
msg db "%d",0
four dd 4 ;word size
three dd 3 ;number of rows nd columns
spce db " ",0
nl db 10
section .bss
arr1 resd 9
section .text
global main
extern printf
main:
nop
xor ecx,ecx
xor eax,eax
xor ebx,ebx
mov ebx, arr1
forI:
xor esi,esi
cmp ecx,3
jl forJ
jmp print
forJ:
cmp esi,3
jl initialization
inc ecx
jmp forI
initialization: ; it will give base address+4(number of colums*rowIndex+columIndex).
;ecx=row index,esi=column index
mov eax,ecx
mul dword[three]
add eax,esi
mul dword[four]
add ebx,eax
mov dword[ebx],0 ;set a[i][j]=0
inc esi
jmp forJ
print:
xor ecx,ecx
xor eax,eax
xor ebx,ebx
mov ebx, arr1
forI_2:
xor esi,esi
cmp ecx,3
jl forJ_2
jmp done
forJ_2:
cmp esi,3
jl print_task
pusha
push nl
call printf
add esp,3
popa
inc ecx
jmp forI_2
print_task:
mov eax,ecx
mul dword[three]
add eax,esi
mul dword[four]
add ebx,eax
pusha
push dword[ebx]
push msg
call printf
add esp,8
popa
pusha
push spce
call printf
add esp,4
popa
inc esi
jmp forJ_2
done:
nop
My intended output will be
0 0 0
0 0 0
0 0 0
But the output comes here is
0123012301230 0 0
Segmentation fault
Still I am looking for your advice.
Thank You
Saugata