Restrict a routine to use a limited set of registers

倖福魔咒の 提交于 2021-01-20 09:32:47

问题


Using compiler option, is it possible to restrict a routine from using certain set of registers?

For example: Restrict a routine to use only R0-R8;

Purpose: If some compiler option available, then I could ensure certain routines (like Interrupt Service Routines) to use only limited register set, and thus do limited Context Save & Restore.


回答1:


When this was last discussed, the consensus was that it is not possible on a function-by-function basis.

There are ways to restrict register use throughout an entire compilation, so if you put your interrupt routines in a separate compilation unit, you can use the gcc switch -ffixed-reg. I believe it would be used like -ffixed-R0 if you wanted the compiler to not generate code using R0.



来源:https://stackoverflow.com/questions/26648496/restrict-a-routine-to-use-a-limited-set-of-registers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!