addi sp, sp, -16 sd ra, 8(sp) sd t0, 0(sp) # 设置参数并调用被调用者函数 li a0, 5 li a1, 10 call callee_function # 恢复调用者保存寄存器 ld t0, 0(sp) ld ra, 8(sp) addi sp, sp, 16 ret # 被调用者函数 callee_function: # 保存被调用者保存寄存器 addi sp, sp, -16 sd s...
.attribute stack_align, 16 .text .align 1 .globl Leaf .type Leaf, @function Leaf: addi sp,sp,-48 # 修改 stack, 降低以 push 值 sw s0,44(sp) # 把 s0 写进 44(sp), s0 这里代表frame pointeraddi s0,sp,48 # s0 = sp + 48, s0 为 frame pointer sw a0,-36(s0) # 把 a0 - a...
使用-O2 -fno-omit-frame-pointer 优化选项得到的编译结果,函数头部有sw s0,8(sp)和addi s0,sp,16,函数尾部有lw s0,8(sp),但是次序和前面的不一样了,这是编译优化导致的编译乱序: 00000000 : 0: 1141 addi sp,sp,-16 2: c4...
1)C.NOP,16 位空操作指令 和32 位的空操作指令类似,C Extension 中也利用目标寄存器为零的加法指令来衍生出空操作指令,即 c.nop = c.addi x0,0 = addi x0,x0,0 2)16 位非法操作指令(Illegal Instruction) 和32 位指令集不同的是,C Extension 专门将全零的编码定义为非法操作指令, 以方便利用硬件异...
a0002c74<custom_cube>:a0002c74:7179addi sp,sp,-48a0002c76:d622 sw s0,44(sp)a0002c78:1800addi s0,sp,48a0002c7a:fca42e23 sw a0,-36(s0)a0002c7e:fdc42783 lw a5,-36(s0)a0002c82:0c07e7fb0xc07e7fba0002c86:fef42623 sw a5,-20(s0)a0002c8a:fec42783 lw a5,-20(s0)a0002c8e:853...
addi x0,x0,0 ; 0 = 0 + 0,相当于 nop 空指令 RSIC-V 寄存器说明 5. RV32I 指令解读 5.1 算术与逻辑指令 在RV32I 中包括算术指令(add/sub)、数值比较指令(slt)、逻辑指令(and/or/xor)以及移位指令(sll/srl/sra)这几种指令。 这些指令和其他指令集差不多,它们从寄存器读取两个32位的值,并将32...
.macroSAVE_CONTEXTcsrrw sp,CSR_MSCRATCHCSWL,sp/* Allocate stack space for context saving */#ifndef __riscv_32e addi sp,sp,-20*REGBYTES#elseaddi sp,sp,-14*REGBYTES#endif/* __riscv_32e */STOREx1,0*REGBYTES(sp)STOREx4,1*REGBYTES(sp)STOREx5,2*REGBYTES(sp)STOREx6,3*REGBYTES(sp...
15 addi t1, t1, 1 16 sw t1, 0(t0) 17 li t2, 1 18 bgtu t1,t2,service_loop 19 20 csrw mscratch, sp 21 la sp, __irq_stack_top 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. ...
to restore any registers unique to the RISC-V implementation. */load_xt0,29*portWORD_SIZE( sp )/* mstatus */addit0,t0,0x08/* Set MIE bit so the first task starts with interrupts enabled - required as returns with ret not eret. */csrrwx0,mstatus,t0/* Interrupts enabled from here...
ld tp, 16(sp) ld t0, 24(sp) addi sp, sp, 32 csrrw x0, mstatus, x0 csrrw x0, mie, x0 mret 上述示例代码是一个通用的中断处理函数,它首先保存了一些重要的寄存器的状态,包括ra (返回地址寄存器)、gp (全局指针寄存器)、tp (线程指针寄存器)和t0 (临时寄存器)等。然后,它执行了中断处理的代...