如何解决如何解释程序集并将其编写为类似 RISC 的微操作
我正在学习汇编并遇到了这种做法。
我正在使用的书是:Randal E. Bryant、David R. O’Hallaron - 计算机系统。程序员的观点 [第 3 版](2016 年,Pearson)
我得到了 C 代码的内循环的这段汇编代码,其中有一个累加计算来计算 r。使用 AT&T。
struct ContactView: View {
@Binding var isContactViewActive: Bool
@State var searchBar = ""
var backgroundColor = Color(red: 14/255,green: 18/255,blue: 23/255,opacity: 1.0)
var body: some View {
NavigationView {
ZStack {
backgroundColor
vstack {
HStack {
Button(action: {},label: {
Image(systemName: "magnifyingglass").font(.title)
})
Spacer()
Text("FireChat")
.font(.title)
.fontWeight(.light)
.foregroundColor(Color.white)
Spacer()
Button(action: {},label: {
Image(systemName: "power").font(.title)
})
}.padding(.top,50)
Spacer()
}
}.edgesIgnoringSafeArea(.all)
}
}
}
这是对应的C代码
L3:
mulsd (%rcx,%rax,8),%xmm0
mulsd 8(%rcx,%xmm0
mulsd 16(%rcx,%xmm0
addq $3,%rax
cmpq %r8,%rax
jl .L3
我不确定我应该如何在类似 RISC 的微操作中编写至少几次迭代。
这是我目前拥有的:
double randomproduct(double a[],long n)
{
long i;
double x,y,z;
double r=1;
for (i=0; i<n-2; i+=3) {
x = a[i]; y = a[i+1]; z = a[i+2];
r = r*x*y*z; //accumulation calc
}
for (; i<n; i++)
r *= a[i];
return r;
}
我真的很困惑应该为此使用哪些寄存器/内存位置以及如何编写类似 RISC 的微操作 shd。 请发送帮助,感谢所有帮助。谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。