如何在C程序(AVR)中编写汇编ISR?
继我的其他问题之后,帮助优化此 C (AVR) 代码? :),我刚刚意识到我并不真正了解如何在我的 C 程序中以汇编方式实现 ISR 的机制。我用谷歌搜索,但没有发现任何有用的东西。
基本上我想在我的 C 项目中设置所有其他内容(包括触发中断的寄存器),但我希望中断执行我编写的一些汇编代码。
如果有帮助的话,我正在 Windows 上使用 AVR studio 6。有人告诉我需要使用 .s
文件,但除此之外我不太确定该怎么做。基本结构就是下面这样吗?
#include <avr\io.h>
TIMER1_COMPA_vect:
; assembly instructions here
如果我希望程序集在 TIMER1_COMPA_vect 中断触发时运行(这是 C 中 ISR 的名称)。还是我完全偏离了轨道?我需要做什么的基本模板是什么?或者,如果这是一个愚蠢的问题,是否有一个链接可以让我找到更多信息?
Following on from my other question, Help optimising this C (AVR) code? :), I just realised that I don't really know the mechanics of how to implement an ISR in assembly within my C program. I googled, but I didn't find anything too useful.
Basically I want to set up everything else in my C project (including the registers to get the interrupt to fire), but I want the interrupt to execute some assembly code that I've written.
I'm using AVR studio 6 on Windows if that helps. I've been told I need to use .s
files but apart from that I'm not really sure what to do. Is the basic structure just the following?
#include <avr\io.h>
TIMER1_COMPA_vect:
; assembly instructions here
If I want the assembly to run when the TIMER1_COMPA_vect interrupt is fired (this is the name of the ISR in C). Or am I totally off track? What is a basic template of what I need to do? Or if it's a dumb question, is there a link where I can find more information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
《汇编语言的艺术》(Randall Hyde 着)有两章关于 ISR(第 17 章和第 18 章,特别是第 18.5 和 18.6 节可能对您有帮助)。很快:
顺便说一句,您可以获得那本伟大书的 pdf 副本此处
The Art of Assembly Language (by Randall Hyde) has two chapters about ISRs (17th and 18th, specifically sections 18.5 and 18.6 might help you). Shortly:
By the way, you can obtain a pdf copy of that great book here