addi sp, sp, -16 sd s0, 0(sp) # 函数体 add s0, a0, a1 # s0 = a0 + a1 # 恢复被调用者保存寄存器 ld s0, 0(sp) addi sp, sp, 16 ret
.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...
addi addi rd, rs1, immediate x[rd] = x[rs1] + sext(immediate) 加立即数(Add Immediate). I-type, RV32I and RV64I. 把符号位扩展的立即数加到寄存器 x[rs1]上,结果写入 x[rd]。忽略算术溢出。 压缩形式:c.li rd, imm; c.addi rd, imm; c.addi16sp imm; c.addi4spn rd, imm ...
12: 0141 addi sp,sp,16 14: 8082 ret 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 使用-O2 -fno-omit-frame-pointer 优化选项得到的编译结果,函数头部有sw s0,8(sp)和addi s0,sp,16,函数尾部有lw s0,8(sp),但是次序和前面...
1610250:8082ret0000000000010252:10252:1141addi sp,sp,-1610254:e406 sd ra,8(sp)10256:e022 sd s0,0(sp)10258:0800addi s0,sp,161025a:fd9ff0ef jal ra,102321025e:4781li a5,010260:853e mv a0,a510262:60a2 ld ra,8(sp)10264:6402ld s0,0(sp)10266:0141addi sp,sp,1610268:8082ret 分析...
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...
0x0000000000010182<+42>:addia0,a5,176#0x1c0b0 0x0000000000010186<+46>:jalra,0x10332<printf> 0x000000000001018a<+50>:lia5,0 0x000000000001018c<+52>:mva0,a5 0x000000000001018e<+54>:ldra,24(sp) 0x0000000000010190<+56>:lds0,16(sp)
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 (临时寄存器)等。然后,它执行了中断处理的代...
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...