include /irvine/Macros.inc INCLUDE Irvine32.inc
.data
array DWORD 16 DUP(?)
row dword ?;
col dword ?;
rowsize = 16;
selection BYTE "Please make your selection",0
msg1 BYTE "1.Calculate the sum of the elements of a specified row",0
msg2 BYTE "2.Calculate the sum of the values of a specified column",0
msg3 BYTE "3.Calculate the sum of all of the elements of the array.",0
msg4 BYTE "4.Count the negative numbers in the array.",0
msg5 BYTE "5.Calculate the sum of the diagonal elements of the array.",0
msg6 BYTE "Quit",0
.code main PROC
call Clrscr
mov ecx,16
mov edi,offset array
call Randomize
mov ebx,row
mov edx,col
l1:
call Random16num
mov [edi],eax
add edi,4
loop l1
mov ecx,4
mov esi, offset array
l2: mov ebx,4
l3: mov eax,[esi] mWriteSpace 3 add esi,3 dec ebx jnz l3 call crlf loop l2
l4:
push ebx
mov ebx,16
mul ebx
pop ebx
mov row,eax
mov col,eax
cmp eax,3
jg done
mov ebx,row
mov edx,col
mov eax, array[ebx][ edxtype array]; start of array + row20 + col*4
call writedec
call crlf
call crlf
jmp l4
done:
exit
main ENDP
Random16num PROC
;mov ecx,16 ; loop count (size of array)
mov eax,20
call RandomRange
sub eax,10
call WriteInt
ret
Random16num ENDP
Sum PROC
Sum ENDP
END main