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

[复制链接]
3485|4
 楼主| xuyaqi 发表于 2011-9-20 17:51 | 显示全部楼层 |阅读模式
在c中定义了位变量:
bdata unsigned char AOUTPUT;
sbit CCS       = AOUTPUT^3;

在汇编中要用“CCS”位变量,定义如下:
extrn data(AOUTPUT);
CCS  BIT AOUTPUT.3;
编译通不过必须改为:
CCS  BIT 20h.3;
方能通过。
什么原因,望高手解答。
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;

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
 楼主| xuyaqi 发表于 2011-9-20 21:04 | 显示全部楼层
感谢3楼的回答,问题解决,但不能这样写:
// ASM
EXTRN bit    CCS ;
而是要这样写:
extrn bit    (CCS) ;
编译才能通过。
结贴。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

47

主题

1639

帖子

6

粉丝
快速回复 在线客服 返回列表 返回顶部