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

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

问题描述

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

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.

有多种方法可以在整个编译过程中限制寄存器的使用,因此如果您将中断例程放在单独的编译单元中,则可以使用 gcc 开关 -ffixed-reg.如果您希望编译器不使用 R0 生成代码,我相信它会像 -ffixed-R0 一样使用.

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天全站免登陆