I learnt that in RiscV assembly we save function arguments in registers s0,...,s7 but what if I had more that 8 arguments?
Plus what about the case where I have more than 32 arguments (let's say 40) how this is managed?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI learnt that in RiscV assembly we save function arguments in registers s0,...,s7 but what if I had more that 8 arguments?
Plus what about the case where I have more than 32 arguments (let's say 40) how this is managed?
The calling convention explains the behavoir.
The RISC-V calling convention passes arguments in registers when possible. Up to eight integer registers, a0–a7, and up to eight floating-point registers, fa0–fa7, are used for this purpose.
More will be passed by stack.
Though, 40 arguments to a function may also be a sign of bad code.
How about passing a struct or array pointer?