打印
[C语言]

【菜鸟求助】在keil C51中如何引用外部.A51文件中的汇编宏?

[复制链接]
1528|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
imba_sid|  楼主 | 2015-2-5 10:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在keil环境下,C文件需要引用一个外部的汇编宏,请教21朋友们怎么样可以做到?

亦或,在C51文件中如何定义一个嵌入的汇编宏?

为方便我贴下码源:
portSAVE_CONTEXT        MACRO               
                /* Push ACC first, as when restoring the context it must be restored
                last (it is used to set the IE register).  */
                PUSH                ACC               
                /* Store the IE register then disable interrupts. */                                       
                PUSH                IE               
                PUSH                B
                PUSH                DPX
                PUSH                DPH
                PUSH                DPL
                PUSH                PSW
                PUSH                AR0
                PUSH                AR1
                PUSH                AR2
                PUSH                AR3
                PUSH                AR4
                PUSH                AR5
                PUSH                AR6
                PUSH                AR7       
        ENDM

相关帖子

沙发
imba_sid|  楼主 | 2015-2-5 10:49 | 只看该作者
求助,

使用特权

评论回复
板凳
imba_sid|  楼主 | 2015-2-5 11:06 | 只看该作者
在SDCC中是如下定义的:

/*
* Macro to push the current execution context onto the stack, before the stack
* is moved to XRAM.
*/
#define portSAVE_CONTEXT()                                                                                                                                                \
{                                                                                                                                                                                                \
        _asm                                                                                                                                                                                \
                /* Push ACC first, as when restoring the context it must be restored                                        \
                last (it is used to set the IE register). */                                                                                        \
                push        ACC                                                                                                                                                                \
                /* Store the IE register then disable interrupts. */                                                                        \
                push        IE                                                                                                                                                                \
                clr                _EA                                                                                                                                                                \
                push        DPL                                                                                                                                                                \
                push        DPH                                                                                                                                                                \
                push        b                                                                                                                                                                \
                push        ar2                                                                                                                                                                \
                push        ar3                                                                                                                                                                \
                push        ar4                                                                                                                                                                \
                push        ar5                                                                                                                                                                \
                push        ar6                                                                                                                                                                \
                push        ar7                                                                                                                                                                \
                push        ar0                                                                                                                                                                \
                push        ar1                                                                                                                                                                \
                push        PSW                                                                                                                                                                \
        _endasm;                                                                                                                                                                        \
                PSW = 0;                                                                                                                                                                \
        _asm                                                                                                                                                                                \
                push        _bp                                                                                                                                                                \
        _endasm;                                                                                                                                                                        \
}
/*-----------------------------------------------------------*/

在keil中我把_asm        替换为#pragma asm 会提示#出错。

使用特权

评论回复
地板
ayb_ice| | 2015-2-5 13:31 | 只看该作者
C当然不可以引用外部的宏了

做成子程序,声明好后,就可以调用了

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

5

帖子

0

粉丝