GetCode
movlw 0xF0 ;avoids use of "count" register
movwf temp ;put counter in temp
movlb 0 ;not necessary -- already |B0
movlw 0x0C ;form feed
call Put232 ;clear screen cursor at 0,0
DelayCy (5*msecs)
StrPrint "Enter Code: " ;12 char +4 code, advances to line 1,0
_Code
lslf temp,f
movlb 7 ;check IOC flags
clrf IOCBF
btfss INTCON,IOCIF ;wait for button push
bra $-1
call Debounce ;short delay (optional)
movlw 0x01
btfss IOCBF,SW1 ;not messed up if >1 switch set
bcf WREG,0
addwf temp,f
addlw 0x30
call Put232 ;print 0 or 1 , returns in |B0
NextBit
movf PORTB,w
andlw 0xA0 ;mask all but SW1(5) and SW2(7)
btfss STATUS,2 ;test for release of both switches
bra $-3 ;wait for release
movlb 7
clrf IOCBF ;clears INTCON,IOCIF too
btfsc temp,7
bra _Code
call Confirm? ;prints & returns with flag0,0 set(yes) or clear(no)
btfss flag0,0
goto Main ;exit to Main
bra PutMode
PutMode
movf temp,w
brw
goto Default ;return all registers to default, Status: untested
;and so forth