限制例程使用一组有限的寄存器 [英] Restrict a routine to use a limited set of registers

查看:140
本文介绍了限制例程使用一组有限的寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用编译器选项,是否可以限制例程使用某些寄存器集?

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

例如:将例程限制为仅使用R0-R8;

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.

推荐答案

最后讨论,共识是不可能逐个功能地进行.

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.

这篇关于限制例程使用一组有限的寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆