本帖最后由 457878 于 2011-12-8 17:55 编辑
变量定义在bank3中,全是banksel !是不是可以减少一点【banksel 】?
_SPI_Send_Byte:
banksel bytData
movwf bytData ;bytData = w;
Mmov bytCnt,.8 ;n=8;
banksel STATUS
goto l3 ;while(n--)
l4:
call _Delay100us
banksel STATUS
bcf CLK ;CLK = 0 ;
banksel bytData
btfss bytData,7 ;if((dat&0x80) == 0x80)
goto l6
banksel STATUS
bsf MOSI ;MOSI = 1 ;
goto l7
l6:
banksel STATUS
bcf MOSI ;MOSI = 0 ;
l7:
call _Delay100us
banksel STATUS
bcf STATUS,C ;dat = dat<<1;
banksel bytData
rlf bytData
banksel STATUS
bsf CLK ;CLK = 1 ;
l3:
banksel bytCnt
decf bytCnt
incfsz bytCnt,w
goto l4
return |