. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->自由讨论区
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  c语言改写成汇编  [待解决] 回复[ 2次 ]   点击[ 226次 ]  
llxlf2012
[帖 主]   [ 发表时间:2011-11-27 12:12 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-11-27 12:04
1.请问像这样的比较工整的矩阵的相乘怎么样改写为汇编?
2.再问改写为汇编后代码的大小会减少吗?
t32BITS term1, term2, term3, termSum;
          

    term1=srcM1[0]*srcM2[0];

    term2=srcM1[1]*srcM2[3];

    term3=srcM1[2]*srcM2[6];

    termSum = term1 + term2 + term3;

    term1=srcM1[0]*srcM2[1];

    term2=srcM1[1]*srcM2[4];

    term3=srcM1[2]*srcM2[7];

    termSum = term1 + term2 + term3;


    term1=srcM1[0]*srcM2[2];

    term2=srcM1[1]*srcM2[5];

    term3=srcM1[2]*srcM2[8];


    termSum = term1 + term2 + term3;


    term1=srcM1[3]*srcM2[0];

    term2=srcM1[4]*srcM2[3];

    term3=srcM1[5]*srcM2[6];


    termSum = term1 + term2 + term3;

    
term1=srcM1[3]*srcM2[1];

    term2=srcM1[4]*srcM2[4];

    term3=srcM1[5]*srcM2[7];



    termSum = term1 + term2 + term3;
   

    term1=srcM1[3]*srcM2[2];

    term2=srcM1[4]*srcM2[5];

    term3=srcM1[5]*srcM2[8];

    

    termSum = term1 + term2 + term3;
    

    term1=srcM1[6]*srcM2[0];

    term2=srcM1[7]*srcM2[3];

    term3=srcM1[8]*srcM2[6];


    termSum = term1 + term2 + term3;

    term1=srcM1[6]*srcM2[1];

    term2=srcM1[7]*srcM2[4];

    term3=srcM1[8]*srcM2[7];
   

    termSum = term1 + term2 + term3;


    term1=srcM1[6]*srcM2[2];

    term2=srcM1[7]*srcM2[5];

    term3=srcM1[8]*srcM2[8];


    termSum = term1 + term2 + term3;
tomato
[第1楼]   [ 回复时间:2011-11-27 13:14 ]   [引用]   [回复]   [ top ] 
荣誉值:405
信誉值:0
注册日期:2008-01-19 14:51
可以使用汇编中的乘法指令mul和加法指令add。具体代码是否会减少,你可以试一下。或许会减少。
llxlf2012
[第2楼]   [ 回复时间:2011-11-27 20:24 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-11-27 12:04
回复:[第1楼]
------------------
谢谢
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved