← index #2889PR #4855
Off-topic · high · value 1.154
QUERY · ISSUE

Document need (or no need) to save & restore registers in asm_xtensa functions

openby ARF1opened 2017-02-20updated 2024-09-29
docsport-esp8266

I am discovering micropython for the esp8266 and am absolutely astonished at what is possible already!

One thing I am struggling with is the machine.asm_xtensa decorator which so far is undocumented.

Most things can be understood by analogy to the documented machine.asm_thumb decorator, but one thing absolutely stumps me:

Does one have to save and restore any registers one modifies in an asm_xtensa function? If so, are there any convenient solutions for doing so, or does one have to all the stack pointer algebra oneself? The asm_thumb instruction push({...}) looks great!

CANDIDATE · PULL REQUEST

py/nlrthumb: Save and restore some VFP registers.

closedby dpgeorgeopened 2019-06-17updated 2019-06-19

These s16-s21 registers are used by gcc so need to be saved. It seems that gcc doesn't use any higher registers (s22-s31) so as an optimisation (for C stack usage, and time storing/loading them) they are not saved/restored.

See issue #4844

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied