Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    自己动手编写一个非常简单的RISC-V C调用使用ABI规则ASM汇编的demo, 使用qemu-riscv64虚拟机测试.

    MR Series
    1
    1
    691
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • tigger
      tigger LV 7 last edited by

      hello.c

      #include <stdio.h>
      
      extern int plus(int a, int b);
      
      int main(void)
      {
              printf("hello, %d\n", plus(111, 222));
      }
      

      plus.S

      .text
      
      .global plus
      
      plus:
              add     a0,a1,a0
              ret
      

      编译:

      riscv64-linux-gnu-gcc -o hello hello.c plus.S -g
      

      运行:

      $ QEMU_LD_PREFIX=/usr/riscv64-linux-gnu/ qemu-riscv64 hello
      hello, 333
      
      1 Reply Last reply Reply Quote Share 0
      • Referenced by  Kirin Kirin 
      • 1 / 1
      • First post
        Last post

      Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

      行为准则 | 用户协议 | 隐私权政策