I read here that a jmpl
instruction must be followed by nop
.
The SPARC V8 manual tells me that an rett
instruction must always be preceded by a jmpl
instruction.
But, I haven't been able to find a relation between jmpl
and restore
instructions. I am currently working on SPARC V8 architecture and one of the ELF files I encountered has a restore
right after jmpl
, while I expected an nop
. I don't know if this is correct or the ELF (and by extension the SPARC code) is wrong.
Is having restore
right after jmpl
correct?
I read here that a
jmpl
instruction must be followed bynop
.
... and the page you linked tells you why:
So when you program in SPARC, follow every
call
andjmpl
instructions with anop
instruction to avoid executing an extra instruction unintentially ...
This means: The nop
is not a requirement of the CPU, but it is an advise of the author of the web page for programmers to avoid errors.
On another page of the same course the author explains that a professional programmer (or a C compiler) would use the following sequence to return from a function:
jmpl %i7+8, %g0
restore
This means that it is not only allowed to use restore
in the delay slot of the jmpl
instruction, but it is even the normal sequence for returning from a function.