DISPLAY = 204 ;Display 162 = 16X2 character, 204 = 20x4
IF DISPLAY == 204
; user code
ENDIF
IF DISPLAY == 162
; user code
ENDIF
SWITCH: movwf tmp ; Save the input value
movlw HIGH (table + 1) ; Calculate the start of the table
movwf PCLATH ;
movf tmp,w ;
addlw LOW (table + 1) ; Add input value to Table Pointer
btfsc STATUS,C ;
incf PCLATH,f ; Adjust table start if it crosses a boundary of 256.
table: movwf PCL
goto L0
goto L1
goto L2
goto L3
L0: ; Put your code here for W = 0
return
L1: ; Put your code here for W = 1
return
L2: ; Put your code here for W = 2
return
L3 ; Put your code here for W = 3
return
I'm new to this forum, how can I thank you guys? are there are any reputation scoring in here?
The following example is a working example of how a switch statement can be made, NOTE only works if your index value is like in your example 0,1,2,3,4,5,6,7 etc..
Code:SWITCH: movwf tmp ; Save the input value movlw HIGH (table + 1) ; Calculate the start of the table movwf PCLATH ; movf tmp,w ; addlw LOW (table + 1) ; Add input value to Table Pointer btfsc STATUS,C ; incf PCLATH,f ; Adjust table start if it crosses a boundary of 256. table: movwf PCL goto L0 goto L1 goto L2 goto L3 L0: ; Put your code here for W = 0 return L1: ; Put your code here for W = 1 return L2: ; Put your code here for W = 2 return L3 ; Put your code here for W = 3 return
SWITCH: movwf tmp ; Save the input value
movlw HIGH (table + 1) ; Calculate the start of the table
movwf PCLATH ;
movf tmp,w ;
addlw LOW (table + 1) ; Add input value to Table Pointer
btfsc STATUS,C ;
incf PCLATH,f ; Adjust table start if it crosses a boundary of 256.
table: movwf PCL
goto L0
goto L1
goto L2
goto L3
goto L4
goto L5
goto L6
goto L7
L0: ; Put your code here for W = 0
nop etc..
nop etc..
return
L1: ; Put your code here for W = 1
return
L2: ; Put your code here for W = 2
return
L3 ; Put your code here for W = 3
return
L4: ; Put your code here for W = 4
return
L5: ; Put your code here for W = 5
return
L6: ; Put your code here for W = 6
return
L7 ; Put your code here for W = 7
return
;------ if routine
_IF movf x,w
sublw .1
bnz _FALSE
_TRUE ;CODE BODY HERE!
_FALSE ;FAILED IF TEST
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?