How Many $t Registers Are There
$S or $T used equally temporary registers in associates
Sorry I'm bothering you with such a picayune question, just the internet is vast and I cannot detect an answer.
According to the manual tin S0 - S7 be used by a called function, without preserving them. It'due south said that the Caller has to preserve them.
Simply in the MPLAB Ten Help file for XC32, there is a code example:
asmFunction:
/* function prologue - save registers used in this function
* on stack and adjust stack-arrow
*/
addiu sp, sp, -4
sw s0, 0(sp)
la s0, LATACLR
sw a0, 0(s0) /* articulate specified bits */
I'm just showing the starting time. Here, the S0 register is saved, even though the caller is supposed to preserve these registers before calling this role. Wouldn't the example code accept used the T0 register instead?
Well, there is an ambiguity here, and I'm glad if I don't will discover the solution to this mystery the hard ( nerve wrecking ) way.
Then, the key question is; are the S registers the ones that do not need to be backed upward past the called office? Or is it the T ones?
Thanks.
Re: $Southward or $T used as temporary registers in assembly 2020/01/23 08:16:xiv (permalink)
S0-s7 are callee-saved registers, ie. a called part must preserve their values. T0-t9 are caller-saved registers, and can be used without saving them. Come across section 12.three of the XC32 transmission.
Re: $S or $T used as temporary registers in assembly 2020/01/23 08:26:39 (permalink)
Re: $S or $T used as temporary registers in assembly 2020/01/25 13:34:00 (permalink)
Ha! confusing!
Wikipedia:
For the N32 and N64 ABIs, a office must preserve the $S0-$s7 registers, the global pointer ($gp or $28), the stack pointer ($sp or $29) and the frame arrow ($30).
XC32 help:
s0-s7
Temporary registers whose values are saved across part calls.
The Wiki version suggests that a function must preserve s0-s7 on function entry.
The XC32 help is more than cryptic. I interpreted it as a calling function must backup them before calling. But I presume the Wikipedia version is correct.
I would have preferred this way of putting it:
S0-S7 ; a called role may not utilise these registers without backing them up on entry, and restoring them on go out.
A typical problem with engineers. They know everything, and they can't imagine how it feels non to sympathise everything, so they cannot really effigy out what information is more of import than others. That'due south why manuals ever volition be a mess.
OK, do you concord with Wikipedia? The t0-t9 would exist the ones to utilize.
Re: $Due south or $T used as temporary registers in assembly 2020/01/25 14:29:04 (permalink)
henkebenke
A typical trouble with engineers. They know everything, and they can't imagine how it feels not to understand everything, so they cannot really figure out what information is more important than others. That'southward why manuals ever will exist a mess.
Manuals are not written by engineers. I believe they would be much improve if they were.
Re: $Southward or $T used as temporary registers in assembly 2020/01/25 15:10:41 (permalink)
XC32 uses the O32 ABI. The N32 and N64 ABIs only exist for 64-bit MIPS CPUs.
henkebenkeXC32 help:
s0-s7
Temporary registers whose values are saved across function calls.The Wiki version suggests that a office must preserve s0-s7 on office entry.
The XC32 aid is more ambiguous. I interpreted it as a calling function must fill-in them before calling. But I assume the Wikipedia version is right.
They say the aforementioned thing. If a register'due south value is preserved across a function call, then the called function must save the register before touching information technology.
postal service edited by andersm - 2020/01/25 15:16:34
Re: $S or $T used as temporary registers in assembly 2020/01/25 sixteen:25:01 (permalink)
I retrieve the OP would prefer if "are" was changed to "must exist". :)
I besides mail at: PicForum
To become a useful respond, always country which PIC you are using!
Re: $S or $T used equally temporary registers in assembly 2020/01/25 16:57:32 (permalink)
The caller is responsible for saving and restoring any of the post-obit caller-saved registers that it cares about: $t0-$t9, $a0-$a3, and $v0-$v1. In other words, the callee may freely modify these registers, under the assumption that the caller already saved them if necessary.
The callee is responsible for saving and restoring whatsoever of the following callee-saved registers that it uses: $s0-$s7, $gp, $sp, $fp (or $s8), and $ra. So the caller may presume these registers are not inverse past the callee.
Be very careful when writing nested functions which act as both a caller and a callee. ;)
post edited past 1and0 - 2020/01/25 eighteen:40:09
Re: $S or $T used as temporary registers in associates 2020/01/25 16:58:59 (permalink)
Then the question becomes must be saved by whom? Most literature uses the terms caller- and callee-saved registers.
Re: $S or $T used as temporary registers in assembly 2020/01/28 03:49:x (permalink)
This post was helpfull, thanks
Re: $S or $T used as temporary registers in assembly 2020/02/08 x:55:48 (permalink)
Ha, the defoliation continues. I found this in "Section 50 - CPU" DS60001192B.
r8 - r15 t0-t7 Temporary – Caller does not need to preserve contents.
r16 - r23 s0-s7 Saved Temporary – Caller must preserve contents
At present that is totally wrong!
I have now witnessed three pieces of data in this matter.
1. The one in the Help file of MPLABX - that 1 is cryptic.
ii. Wikipedia - that ane is correct. ( Wikipedia is always right )
3 Department 50 - that one is incorrect.
This is actually an important topic. Who wants to save registers when he don't need to?
Simply now you know guys, Wikipedia is ever right!
Re: $S or $T used as temporary registers in associates 2020/02/08 14:09:43 (permalink)
henkebenke
This is actually an important topic. Who wants to save registers when he don't need to?
Write the whole affair in assembler. Then you don't need to worry about calling conventions - everything is entirely up to you. Yous will need to salvage even less :)
Re: $S or $T used as temporary registers in assembly 2020/02/08 14:59:35 (permalink)
NorthGuyWrite the whole matter in assembler. Then yous don't need to worry nearly calling conventions - everything is entirely up to you. Y'all will need to save even less :)
+ane
Those conventions are not enforced by the hardware or assembler. It is the programmers agreeing to them so functions written by dissimilar people can interface with each other. When you write the whole affair in associates yourself, you're in total control. ;)
How Many $t Registers Are There,
Source: https://www.microchip.com/forums/m1125793.aspx
Posted by: tapiatindst.blogspot.com

0 Response to "How Many $t Registers Are There"
Post a Comment