chrismicro Site Admin

Joined: 16 Jan 2008 Posts: 15 Location: South Africa
|
Posted: Sun Mar 09, 2008 7:48 pm Post subject: How a LOOK UP table work |
|
|
A look up table, is what it say, a list of data that is used in programing of micro controllers, it is a table that the program use to look up data that it need to do the job, it is a list of data and each data item is associated with a index, in other words where in the table it is:
PICBasic Example
| Code: |
FOR B0 = 0 TO 5 ' Count from 0 to 5
LOOKUP B0,["Hello!"],B1 ' Get character number B0 from string to variable B1
SEROUT 0,N2400,[B1] ' Send character in B1 to Pin0 serially
NEXT B0 ' Do next character
|
In this example the word "Hello" is the table, the For loop put a number from 0 to 5 in the variable B0 then starting with 0 it look up in the table what is the value, it find an "H" in position 0 so it place the "H" in variable B1 then it send that character out to the serial port, in the next count B0 will be 1 and the program will find an "e" in that position and so on, to the end of the loop.
PIC ASM Example:
| Code: |
;Binary to 7-segment display decoder program
CLRW
TRIS 06 ;Set B as outputs, A as inputs
START MOVF 05,W ;Load W from Port A
CALL TABLE ;Load W from lookup table
MOVWF 06 ;Output data to Port B
GOTO START ;End of loop
TABLE ADDWF 02,1 ;Lookup table
RETLW 3F ;0
RETLW 06 ;1
RETLW 5B ;2
RETLW 4F ;3
RETLW 66 ;4
RETLW 6D ;5
RETLW 7D ;6
RETLW 07 ;7
RETLW 7F ;8
RETLW 6F ;9
END
|
_________________ To become free, the Boervolk have to get the Afrikaner out of his soul and reject it, to regain his Boer pride.
Om vry te word, moet die Boervolk eers die Afrikaner uit sy siel haal en verwerp, om sy Boere trots te herwin. |
|