文章目录
题目描述
编写一个矩阵乘法程序,实现元素为正整数的矩阵的乘法,规模灵活设置
程序功能:
1、 程序带有3个命令行参数.依次为矩阵1数据文件名,矩阵2数据文件名,输出数据文件名。如下:
程序命令 矩阵1数据文件名 矩阵2数据文件名 输出文件名
2、 dos窗口中执行命令后将计算结果显示在屏幕上并保存到输出文件中。
3、 三个数据文件均以文本的格式存储了矩阵的数据,例如.
矩阵数据文件的内容为矩阵内容,数字中间以空格分隔
12 11 6
11 11 7
11 10 7
矩阵2数据文件的内容为:
2
3
4
则输出文件的内容为.
81
83
80,
如果矩阵1的列数和矩阵2的行数不匹配,则报错。
流程图
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZbLuLWjy-1591538967059)(file:///C:/Users/ROBINV~1/AppData/Local/Temp/msohtmlclip1/01/clip_image002.png)]
程序代码
include Irvine32.inc
Read_Text PROTO
Change_to_M PROTO
Cal_M PROTO
Output_File PROTO
GetCommandtail PROTO
PDWORD TYPEDEF PTR DWORD
PB TYPEDEF PTR BYTE
.data
M1 DWORD 10000 DUP (0);三个矩阵
M2 DWORD 10000 DUP (0)
M3 DWORD 10000 DUP (0)
row1 DWORD ?;矩阵行列信息
row2 DWORD ?
col1 DWORD ?
col2 DWORD ?
i1 DWORD ?
i2 DWORD ?
filehandle DWORD ?
now1 PDWORD ?;指针
now11 PDWORD ?
now2 PDWORD ?
now22 PDWORD ?
now3 PDWORD ?
jump1 DWORD ?
jump2 DWORD ?
start PDWORD ?
row PDWORD ?
col PDWORD ?
buff_tmp PB ?
num DWORD ?
text BYTE 600 DUP(0);输入命令行
input1 BYTE 200 DUP(0)
input2 BYTE 200 DUP(0)
input PB ?
output BYTE 200 DUP(0)
input1_size DWORD 0
input2_size DWORD 0
output_size DWORD 0
eccx DWORD 0
cnt DWORD 1
wa1 BYTE "Wrong Input!",0
wa2 BYTE "Open File Failed!",0
wa3 BYTE "Can't Calculate!",0
accept BYTE 'The answer matrix is',10,0
buff BYTE 10000 dup(?)
buff_size DWORD 0
.code
main PROC
mov edx,offset text ;读入命令行
call GetCommandtail
call Read_Text
mov al,input1[0] ;文件名是否正常识别
cmp al,00h
je err1
mov al,input2[0]
cmp al,00h
je err1
mov al,output[0]
cmp al,00h
je err1
mov start,offset M1
mov edx,offset input1
mov row,offset row1
mov col,offset col1
call Change_to_M
mov start,offset M2
mov edx,offset input2
mov row,offset row2
mov col,offset col2
call Change_to_M
mov eax,col1
cmp eax,row2
jne err3
mov edx,offset accept
call writestring
call Cal_M
call Output_File
exit
err1:
mov edx,offset wa1