Write a program which for a square matrix to calculate the sum of the elements. Assume that the amount can be placed in 16-bit register

Example:


1 1 1
2 2 2
3 3 3

Elements are: 1,1, 2, which are with red color. I had calculate sum of this elements.

Please help me!!!

DX will contain required sum:

mov     dx,0
        mov     esi,matr
        mov     ecx,0
        mov     cx,[dimmatr]
        mov     eax,1
mRow:
        push    ecx

        mov     cx,[dimmatr]
        mov     ebx,0
mCol:
        cmp     ebx,eax
        jl      msk
        add     dx,word [esi]
msk:
        inc     ebx
        add     esi,2
        loop    mCol
        inc     eax

        pop     ecx
        loop    mRow

dimmatr dw 3;matrix dimension
matr    dw 1,1,1,2,2,2,3,3,3;matrix
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.