资源描述:
《实现io端口直接位定义操作的一个示例(an example of how to implement the io port direct bit definition operation)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实现io端口直接位定义操作的一个示例(AnexampleofhowtoimplementtheIOportdirectbitdefinitionoperation)IAR-Csoftwarehasapowerfulsimulationfunction,buttheregisterdefinitionisverycumbersomeoperation,ASMcoderedundancyandcompiled,inordertosolvethisproblem,amethodofselfdefinedmoderatoroperationdefinition,beginnerscanrefer
2、tothedefinition,andthismethodcanbeappliedtoallregisterbitoperationdefinition.Atotaloffourbitoperationsareimplemented,suchassettingthebit--Set_Bit,clearingthebit--Clr_Bit,takingthereversebitCom_Bit,andtestingthebitTest_Bit,Andeachbitoperationdefinitiononlyneedsa3byteASMinstructionsequence,anditiss
3、impleanddirect//*****************************************************//P00bitoperationdefinition#defineSet_P00(P0=P0
4、0x1)#defineClr_P00(P0=P0&~0x1)#defineCom_P00(P0=P0^0x1)#defineTest_P00(P0&0x1)//P01bitoperationdefinition#defineSet_P01(P0=P0
5、0x2)#defineClr_P01(P0=P0&~0x2)#defineCom_P01(P0=P0^0x2
6、)#defineTest_P01(P0&0x2)//P02bitoperationdefinition#defineSet_P02(P0=P0
7、0x4)#defineClr_P02(P0=P0&~0x4)#defineCom_P02(P0=P0^0x4)#defineTest_P02(P0&0x4)//P03bitoperationdefinition#defineSet_P03(P0=P0
8、0x8)#defineClr_P03(P0=P0&~0x8)#defineCom_P03(P0=P0^0x8)#defineTest_P03(P0&0x8)//P04bitoperationdefi
9、nition#defineSet_P04(P0=P0
10、0x10)#defineClr_P04(P0=P0&~0x10)#defineCom_P04(P0=P0^0x10)#defineTest_P04(P0&0x10)//P05bitoperationdefinition#defineSet_P05(P0=P0
11、0x20)#defineClr_P05(P0=P0&~0x20)#defineCom_P05(P0=P0^0x20)#defineTest_P05(P0&0x20)//P06bitoperationdefinition#defineSet_P06(P0=P0
12、0x40)#defi
13、neClr_P06(P0=P0&~0x40)#defineCom_P06(P0=P0^0x40)#defineTest_P06(P0&0x40)//P07bitoperationdefinition#defineSet_P07(P0=P0
14、0x80)#defineClr_P07(P0=P0&~0x80)#defineCom_P07(P0=P0^0x80)#defineTest_P07(P0&0x80)//*************************************//P1portoperationbitdefinitions//P10bitoperationdefiniti
15、on#defineSet_P10(P1=P1
16、0x1)#defineClr_P10(P1=P1&~0x1)#defineCom_P10(P1=P1^0x1)#defineTest_P10(P1&0x1)//P11bitoperationdefinition#defineSet_P11(P1=P1
17、0x2)#defineClr_P11(P1=P1&~0x2)#defineCom_P11(P1=P1^0x2)#defineTest_P1