c - Sparc 过程调用约定

标签 c assembly sparc

我想在 Sparc 中进行一些“内联”汇编编程,我想知道如何通过寄存器传递来做到这一点。

最好用一个小例子来解释我的问题

int main()
{
   int a = 5;
   int b = 6;
   int res;

   asm_addition(a,b);

   printf("Result: %d\n", res);
   return(0);
}
  // My assembler addition

.global asm_addition            

.align  4   

    add rs1, rs2, rd
    restore

有谁知道我必须使用哪些寄存器才能将值 a 和 b 相加?最后,我需要为 rd 指定哪个寄存器,以便随后将结果与最后一个 printf 语句一起打印在汇编例程之后。

非常感谢您的一些意见!

最佳答案

调用约定可能取决于操作系统。我假设是 Solaris。 Google for system v application binary interface sparc,PDF 很容易找到。

完整的内联汇编程序文档隐藏在 SunStudio PDF 的某处,并不容易找到。官方也可以通过 man -s 1 inline 访问它,但在我的系统上我必须手动打开文件。在手册页中,查找“SPARC 系统的编码约定”。

关于c - Sparc 过程调用约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3256119/

相关文章:

android - 如何在 C 中编写 ffmpeg 命令 shell

汇编 x86 MASM 循环分析

.net - native 代码、机器代码和汇编代码有什么区别?

c - 在汇编程序中指定数组

c - sparc64 上的 DBX 核心转储和堆栈跟踪输入/输出寄存器

c - "Chances"函数发生吗?

c - 在 C 中保存结构地址的变量的数据类型应该是什么?

c++ - 为什么 Direct3D 没有自己的顶点结构?

c - 将 C 代码转换为 MIPS 汇编——使用数组

c++ - boost +CMake : no suitable build variant