打印

在汇编中如何调用c中定义过的位变量望高手解答

[复制链接]
2178|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
xuyaqi|  楼主 | 2011-9-20 17:51 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
沙发
liang7143| | 2011-9-20 18:00 | 只看该作者
给LZ复制一段keil文档中的原文
sbit
The sbit type defines a bit within a special function register (SFR). It is used in one of the following ways:

sbit name = sfr-name ^ bit-position;
sbit name = sfr-address ^ bit-position;
sbit name = sbit-address;
Where

name is the name of the SFR bit.
sfr-name is the name of a previously-defined SFR.
bit-position is the position of the bit within the SFR.
sfr-address is the address of an SFR.
sbit-address is the address of the SFR bit.

使用特权

评论回复
板凳
xuyaqi|  楼主 | 2011-9-20 18:52 | 只看该作者
感谢2楼的回复,但我的位变量不是特殊功能寄存器位变量,那种位变量我能编译通过。
sbit CLK  = P3 ^ 3;

使用特权

评论回复
地板
ayb_ice| | 2011-9-20 19:16 | 只看该作者
本帖最后由 ayb_ice 于 2011-9-20 19:20 编辑

//---------------------------------------
// C
unsigned char bdata  AOUTPUT;
sbit CCS  =  AOUTPUT^3;

//---------------------------------------
// ASM
EXTRN bit    CCS ;
EXTRN data AOUTPUT;

//---------------------------------------
// ASM(更方便的声明)
EXTRN NUMBER CCS;
EXTRN NUMBER AOUTPUT;

未命名.JPG (180.36 KB )

未命名.JPG

使用特权

评论回复
5
xuyaqi|  楼主 | 2011-9-20 21:04 | 只看该作者
感谢3楼的回答,问题解决,但不能这样写:
// ASM
EXTRN bit    CCS ;
而是要这样写:
extrn bit    (CCS) ;
编译才能通过。
结贴。

使用特权

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

本版积分规则

47

主题

1638

帖子

6

粉丝