8.1.3 - 2


sub edx, edx

; for (j=0; j<N; j++)

push ecx

mov ecx, [N]

push ebx

forj:

; r+=matr[i][j]

add edx, [matr+ebx]

;j++

add ebx, 4

loop forj

; s[k]=r;

mov [s+eax*4], edx

;i++

inc eax

pop ebx

add ebx, esi

pop ecx

loop fori

2.

ideal

p586

model flat

extrn ExitProcess:proc

dataseg

matr dd 1,1,1,1,1

dd 2,2,2,2,2

dd 3,3,3,3,3

dd 4,4,4,4,4

M dd 4

N dd 5

S dd 5 dup (?)

codeseg

begin:

mov esi, [N]

shl esi, 3; ?  i

;for (k=0. i=1; i<M; i+=2, k++){

sub eax, eax; k

mov ecx, [M]

shr ecx, 1

mov ebx, [N]

shl ebx, 2; i

fori:

;r=0;

sub edx, edx

; for (j=0; j<N; j++)

push ecx

mov ecx, [N]

push ebx

forj:

; r+=matr[i][j]

add edx, [matr+ebx]

;j++

add ebx, 4

loop forj

; s[k]=r;

mov [S+eax*4], edx

;i++

inc eax

pop ebx

add ebx, esi

pop ecx

loop fori

call ExitProcess

end begin

.