当前位置:网站首页>RISC-V calling conventions
RISC-V calling conventions
2022-07-30 15:41:00 【Huo Hongpeng】
Register conventions

Preserved across calls?
字面意思是Preserve across calls,什么意思呢,也就是标记为YES的寄存器,It needs to remain unchanged before and after the subroutine is executed.如何做到这一点呢,That's where the subroutine uses theseYESbefore deposit,These registers need to be pushed onto the stack,The values of these registers are restored from the stack after use.
标记为NO的呢,It doesn't care when the subroutine is executed,如果NO寄存器,Subroutines are not desired(callee)before and after execution are changed,That requires the caller of the program(caller)Push the stack before the subroutine is executed,After the subroutine is executed, pop the stack to restore the register value.
总结:标记为YES的需要callee保存(Subroutines are saved by themselves),标记为NO的需要caller保存(调用者保存).
注意:
The way to keep the register value unchanged is not necessarily the only way to push and pop the stack,比入SP是
YESHold after subroutine callSP的值不变,Then you can put it at the beginning of the subroutine
SP减去一个值,at the end of the subroutineSP加上一个值,Keep the pre- and post-call unchanged.As shown in the following program fragment
示例:
(gdb) disass main
Dump of assembler code for function main:
0x0000000000010158 <+0>: addi sp,sp,-32 #Open up the stack size here
0x000000000001015a <+2>: sd ra,24(sp)
0x000000000001015c <+4>: sd s0,16(sp)
0x000000000001015e <+6>: addi s0,sp,32
0x0000000000010160 <+8>: li a5,1
0x0000000000010162 <+10>: sw a5,-20(s0)
0x0000000000010166 <+14>: li a5,2
0x0000000000010168 <+16>: sw a5,-24(s0)
0x000000000001016c <+20>: lw a4,-20(s0)
0x0000000000010170 <+24>: lw a5,-24(s0)
0x0000000000010174 <+28>: addw a5,a5,a4
0x0000000000010176 <+30>: sw a5,-28(s0)
0x000000000001017a <+34>: lw a5,-28(s0)
0x000000000001017e <+38>: mv a1,a5
0x0000000000010180 <+40>: lui a5,0x1c
0x0000000000010182 <+42>: addi a0,a5,176 # 0x1c0b0
0x0000000000010186 <+46>: jal ra,0x10332 <printf>
0x000000000001018a <+50>: li a5,0
0x000000000001018c <+52>: mv a0,a5
0x000000000001018e <+54>: ld ra,24(sp)
0x0000000000010190 <+56>: ld s0,16(sp)
0x0000000000010192 <+58>: addi sp,sp,32 #Restore after use
0x0000000000010194 <+60>: ret
End of assembler dump.
边栏推荐
- CS内网横向移动 模拟渗透实操 超详细
- Troubleshooting TiUP
- SEATA distributed transaction
- Excel uses Visual Basic Editor to modify macros
- Nature Microbiology综述:聚焦藻际--浮游植物和细菌互作的生态界面
- Alluxio for Presto fu can across the cloud self-service ability
- JVM performance tuning
- tiup completion
- Excel使用Visual Basic Editor对宏进行修改
- Sleuth+Zipkin (visualization) service link tracking
猜你喜欢

Go to Tencent for an interview and let people turn left directly: I don't know idempotency!

Sentinel

Alluxio for Presto fu can across the cloud self-service ability

The Prospects of the Metaverse and the Four Tracks

Redis cache penetration, breakdown, avalanche and consistency issues

关于MySQL主从复制的数据同步延迟问题

Flink实时仓库-DWS层(关键词搜索分析-自定义函数,窗口操作,FlinkSql设置水位线,保存数据到Clickhouse)模板代码

GeoServer

B+树索引页大小是如何确定的?

【云原生】灰度发布、蓝绿发布、滚动发布、灰度发布解释
随机推荐
Mysql database query is very slow. Besides the index, what else can be caused?
微服务该如何拆分?
Debug - Notes
(Crypto必备干货)详细分析目前NFT的几大交易市场
瑞吉外卖项目实战Day02
Distributed pre-course: MySQL implements distributed locks
Example of video switching playback (video switching example) code
Go to Tencent for an interview and let people turn left directly: I don't know idempotency!
Fink异步IO的实战(关联维表)
MySql报错:SqlError(Unable to execute query“, “Can‘t create/write to file OS errno 2 - No such file...
GeoServer + openlayers
QIIME2得到PICRUSt2结果后如何分析
MASM32v11编程调用Process32First失败: 程序发出命令,但命令长度不正确
Flink实时仓库-DWS层(状态编程,windowall的使用,数据保存到clickhouse)模板代码
【云原生】服务行业案例-不可预测的并发场景解决方案
timed task corn
GeoServer
Core Topics under Microservice Architecture (2): Design Principles and Core Topics of Microservice Architecture
952. 按公因数计算最大组件大小 : 枚举质因数 + 并查集运用题
ECCV2022 | FPN错位对齐,实现高效半监督目标检测 (PseCo)