狂宅 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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序