کد
.model small .data row db ? col db ? tot db ? rows db 10,13,"Enter the no. of rows:$" cols db 10,13,"Enter the no. of columns:$" matd1 db 10,13,"Enter the first matrix:",10,13,"$" matd2 db 10,13,"Enter the second matrix:",10,13,"$" totald db 10,13,"The sum is:",10,13,"$" space db " $" newline db 10,13,"$" mat1 db 100 dup ("$") mat2 db 100 dup ("$") total db 100 dup ("$") .code start: mov ax,@data mov ds,ax lea dx,rows mov ah,09h int 21h mov ah,01h int 21h sub al,30h mov row,al lea dx,cols mov ah,09h int 21h mov ah,01h int 21h sub al,30h mov col,al mov al,row mul col mov tot,al lea dx,matd1 mov ah,09h int 21h mov bl,row lea si,mat1 top: mov cl,col back: mov ah,01h int 21h lea dx,space mov ah,09h int 21h cmp al,41h jc temp sub al,07h temp: sub al,30h and al,0fh mov [si],al inc si loop back lea dx,newline mov ah,09h int 21h dec bl jnz top lea dx,matd2 mov ah,09h int 21h mov bl,row lea si,mat2 top1: mov cl,col back1: mov ah,01h int 21h lea dx,space mov ah,09h int 21h cmp al,41h jc temp1 sub al,07h temp1: sub al,30h and al,0fh mov [si],al inc si loop back1 lea dx,newline mov ah,09h int 21h dec bl jnz top1 lea dx,totald mov ah,09h int 21h lea si,mat1 lea di,mat2 mov bh,row top2: mov cl,col back2: mov al,[si] mov bl,[di] add bl,al cmp bl,10h jc temp2 mov dl,31h mov ah,02h int 21h sub bl,10h cmp bl,0ah jc ans add bl,07h ans: add bl,30h mov dl,bl mov ah,02h int 21h jmp temp3 temp2: mov dl,30h mov ah,02h int 21h cmp bl,0ah jc ans1 add bl,07h ans1: add bl,30h mov dl,bl mov ah,02h int 21h temp3: lea dx,space mov ah,09h int 21h inc si inc di loop back2 lea dx,newline mov ah,09h int 21h dec bh jnz top2 mov ah,4ch int 21h end start
منبع:: انجمن دانشجویان کردستان