新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > SDBC的特殊寄存器(可位尋址的定義方法)

SDBC的特殊寄存器(可位尋址的定義方法)

作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
AT89X52.BI
用于52兼容MCUConst 變量和 Const 變量在編譯的時(shí)候運(yùn)算完By 萬(wàn)致遠(yuǎn),sdbc 定義可位尋址的數(shù)據(jù)類型Type SFR_BIT_ADim SFR_BIT_A As sfr 定義字節(jié)地址sfr,如果Type里有和Type名一樣的變量,則編譯器將把它當(dāng)作默認(rèn)變量比如說(shuō)這個(gè)type里面有SFR_BIT_A,那么外部給這個(gè)類定位地址,事實(shí)上是給這個(gè)變量定位地址比如Dim P0 As SFR_BIT_A at &H80,那么P0=0就是相當(dāng)于MOV #80H,0.然后設(shè)計(jì)如果需要數(shù)字變量名,需要在前面加$,但是如果在類外/類型外引用,則不需要,with語(yǔ)句也需要類似P0.0=1。With P0 .$0=1 End With一樣在type內(nèi)的地址聲明將在編譯時(shí)被固定處理,類似聲明P0在0x80,那么$0~$7固定為0x80~0x87Dim $0 As sbit at &SFR_BIT_ADim $1 As sbit at &SFR_BIT_A+1Dim $2 As sbit at &SFR_BIT_A+2Dim $3 As sbit at &SFR_BIT_A+3Dim $4 As sbit at &SFR_BIT_A+4Dim $5 As sbit at &SFR_BIT_A+5Dim $6 As sbit at &SFR_BIT_A+6Dim $7 As sbit at &SFR_BIT_A+7End TypeIO口定義Dim P0 As SFR_BIT_A at &H80聲明P0在0x80位置Dim P1 As SFR_BIT_A at &H90聲明P1在0x90位置Dim P2 As SFR_BIT_A at &HA0聲明P2在0xA0位置Dim P3 As SFR_BIT_A at &HB0聲明P3在0xB0位置IO口定義結(jié)束


關(guān)鍵詞: SDBC特殊寄存器可位尋

評(píng)論


技術(shù)專區(qū)

關(guān)閉