Name: | Mr. Normando Hall |
Company: | Unixlan |
Web Site: | http://www.unixlan.com.ar |
PIC SNIPETS
Table Call
I use this code for all my tables calls. I put in page3 the tables, and call from any page. Anyway you can put your tables at any adress in your code and then call at any adress too.
This code concist in three blocks: The macro code, the call code, and the table code.
MACRO CODE
This is the macro code, that replaces the variables you pass. You need one variable (_POSTAB).
Tab MACRO number
clrf _POSTAB
bucle#v(number)
movlw High(tab#v(number))
movwf PCLATH
movfw _POSTAB
call tab#v(number)
clrf PCLATH
addlw .0
skpnz
goto out#v(number)
call salida
incf _POSTAB,f
goto bucle#v(number)
out#v(number)
clrf PCLATH
ENDM
TABLE CALL
This is the tables calls rutine block. You need to write one for each table, and place in any location of your program. See the macro invocation the decimal number, correponding to each table, ex: .1 for table 1.
Table1
Tab .1
return
Table2
Tab .2
return
Table3
Tab .3
return
TABLE CODE
Obviusly these are the tables, locate at any adress. If you locate the tables in page 1, forget this snipet
org 0X1800
tab1 addwf PCL,f
dt "Ingrese Password",0X0D,0X0A,0X00
tab2 addwf PCL,f
dt "Password Invalido",0X0D,0X0A,0X00
tab3 addwf PCL,f
dt "-6- Cambio de Password",0X0D,0X0A,0X00
USAGE
Every time you need to call a table, you use:
call Table1 ;(or 2 or 3...)
This snipet is not code optimized, but it is very simple to adapt and use. Of course, exist more betters codes that his. If you know other manner to make the same, tell me. Sorry my english