我有一个C代码,用于调用ARM Assembly中定义的函数。必须传递两个参数。
如果函数调用如下所示:
int main()
{
try {
std::ifstream text_file;
ics::safe_open(text_file,"Enter file name to analyze","C:\\Users\\Xari\\Downloads\\program1\\graph1.txt");
Graph graph = read_graph(text_file);
print_graph(graph);
while (true) {
std::string input;
std::cout << "Enter the name of a starting node (enter quit to quit) D: ";
std::cin >> input;
std::cout << "INVISIBLE DEBUGGER MESSAGE" << std::endl;
if (input != "quit")
std::cout << "Reachable from node name " << input << " = " << reachable(graph, input) << std::endl;
else
break;
}
} catch (ics::IcsError& e) {
std::cout << e.what() << std::endl;
}
return 0;
}
寄存器functionName(a, b)
和x0
按哪个顺序保存这些值?它是x1
持有x0
而a
持有x1
还是相反?
答案 0 :(得分:4)
提出这个问题比花时间更长。
extern void bar ( unsigned int, unsigned int );
void foo ( void )
{
bar(5,7);
}
编译然后反汇编
传统手臂
00000000 <foo>:
0: e3a00005 mov r0, #5
4: e3a01007 mov r1, #7
8: eafffffe b 0 <bar>
aarch64
0000000000000000 <foo>:
0: 528000e1 mov w1, #0x7 // #7
4: 528000a0 mov w0, #0x5 // #5
8: 14000000 b 0 <bar>
c: d503201f nop
MSP430
00000000 <foo>:
0: 3e 40 07 00 mov #7, r14 ;#0x0007
4: 3f 40 05 00 mov #5, r15 ;#0x0005
8: b0 12 00 00 call #0x0000
c: 30 41 ret
PDP-11
00000000 <_foo>:
0: 1166 mov r5, -(sp)
2: 1185 mov sp, r5
4: 15e6 0007 mov $7, -(sp)
8: 15e6 0005 mov $5, -(sp)
c: 09f7 fff0 jsr pc, 0 <_foo>
10: 65c6 0004 add $4, sp
14: 1585 mov (sp)+, r5
16: 0087 rts pc