学校最近在学习e203,需要运行形如addi x1, x0,3 addi x2,x0, 4的汇编。应当自定义S文件,还是使用内联汇编的方式呢?
没人回答我回答了:
两种方法都可以。
#ifdef INLINE1 __asm__ __volatile__( "addi x31, x0, 0 n" "addi x5, x0, 5 n" "addi x6, x0, 3 n" "add x7, x5, x6 n" "sw x7, 0(x31) n" : "=r"(zero) : "r"(one) : "x5", "x6", "x7", "x8", "x9", "x11") #endif #ifdef ASM test_asm(reg_values); #endif
.globl test_asm .type test_asm, @function test_asm: .........