从键盘输入一个4*4的矩阵。
要求:
(1)每个元素都是4位十进制数。
(2)在屏幕上输出该矩阵和它的转置矩阵。
(3)输出这两个矩阵的和(对应元素相加)。
(4)数据的输入和结果的输出都要有必要的提示,且提示独占一行。
(5)要使用到子程序。
代码段
data segment ;数据段
str dw 10 dup(?)
str1 db 'Please input your matrix:',0ah,0dh,'$'
str2 db 'Your matrix is:',0ah,0dh,'$'
str3 db 'Your transpose matrix is:',0ah,0dh,'$'
str4 db 'The sum of matrices is:',0ah,0dh,'$'
crlf db 0ah,0dh,'$'
m1 dw 16 dup(?) ;原始矩阵
m2 dw 16 dup(?) ;转置矩阵
m3 dw 16 dup(?) ;矩阵之和
x dw ? ;判断是否满足四位数
data ends
stack segment stack ;堆栈段
dw 20 dup(?)
stack ends
code segment ;代码段
assume cs:code,ds:data,ss:stack
main proc far
start:
mov ax,data
mov ds,ax
mov ah,09h
lea dx,str1
int 21h
call input_data
mov ah,09h
lea dx,crlf
int 21h
mov ah,09h
lea dx,str2
int 21h
call output_data1
call exchange
mov ah,09h
lea dx,str3
int 21h
call output_data2
mov ah,09h
lea dx,crlf
int 21h
mov ah,09h
lea dx,str4
int 21h
call sum_data
call output_data3
mov ax,4c00h
int 21h
main endp
input_data proc near ;从键盘输入一个4*4矩阵
mov di,0
mov si,0
mov bx,0
L1:
mov ax,0
mov cx,0
mov dx,0
m