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;
这三行代码的意义和意思解释。
这个就是汇编的知识了
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