狂宅 2016-12-26 14:34 采纳率: 0%
浏览 1345
已结题

使用C++,实现将C语言转换汇编语言的编译器的一点小问题

void addsub_asm(ofstream &out,string dsf,string op,string dst,string dsc)
{
out<<" mov BL,"<<dst<<endl;
if(op == "+")
out<<" add BL,"<<dsc<<endl;
else
out<<" sub BL,"<<dsc<<endl;
out<<" mov "<<dsf<<",BL"<<endl;
}

//乘法
void mul_asm(ofstream &out,string dsf,string dst,string dsc)
{
out<<" mov AL,"<<dst<<endl;
out<<" mov BH,"<<dsc<<endl;
out<<" mul BH"<<endl;
out<<" mov BL,1"<<endl;
out<<" div BL"<<endl;
out<<" mov "<<dsf<<",AL"<<endl;
}

//除法
void div_asm(ofstream &out,string dsf,string dst,string dsc)
{
out<<" mov AL,"<<dst<<endl;
out<<" CBW"<<endl
out<<" mov BL,"<<dsc<<endl;
out<<" div BL"<<endl;
out<<" mov "<<dsf<<",AL"<<endl;
}

乘法中
out<<" mov BL,1"<<endl;
out<<" div BL"<<endl;
out<<" mov "<<dsf<<",AL"<<endl;
这三行代码的意义和意思解释。

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-12-26 15:19
    关注
     这个就是汇编的知识了
    out<<" mov AL,"<<dst<<endl; 将dst操作数送入a寄存器的低位
    out<<" mov BH,"<<dsc<<endl; 将dsc送入B寄存器的高位
    out<<" mul BH"<<endl;  把a寄存器低位做乘数,b的高位作为被乘数,相乘, 结果放在a寄存器
    out<<" mov BL,1"<<endl; 将b的地位设置为1
    out<<" div BL"<<endl; a寄存器作为被除数,用b的低位除
    out<<" mov "<<dsf<<",AL"<<endl; 将a的地位送到dsf
    
    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程