This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 0
L_BYTE equ 0x06
H_BYTE equ 0x07
LFSR 0, 0X40
movf POSTINC0, W;
addwf L_BYTE, F;
incf H_BYTE, F;
decfsz COUNT, F
bra 54 Lookup Table Implementation
• There are two methods for reading a
1. Computed goto
2. Using program ROM (Indexed-ROM
addressing 55 Lookup Table Using Computed Goto
• Prelab: Write a subroutine to output a digit pattern
in the 7-segment LED when given the number. Use
a lookup table using Computed Goto.
lookup 56 Lookup Table Using Computed Goto
• Add an offset to PCL to access the
appropriate item in the table
• retlw will load the desired item to WREG
e.g., SVN_SEG: movf PAT_NUM, W
retlw WREG, W
57 Indexed-ROM addressing mode
• We can use program ROM to store fixed
• Use the db (define byte) directive to
define fixed data in program ROM.
array db 0x00, 0x01, 0x02, 0x03
• ROM:  = 0x00,  = 0x01
 = 0x02,  = 0x0358
0x03 Reading Data Using TBLPTR and TABLAT
• To access data in a location in ROM, we
need a register specifying which
location we want to access TBLPTR
• TBLPTR must have 21 bits to address
the whole range of ROM.
• TBLPTR is divided into three 8-bit parts:
TBLPTRL (low), TBLPTRH (high),
• We need a register to store the data
fetched by a table read operation 59
TABLAT Table Read Operations
– After read, TBLPTR stays the same • tblrd*+
– Reads then increments TBLPTR
increments • tblrd*– Reads then decrements TBLPTR
decrements • tblrd+*
– Increments TBLPTR then reads
60 Steps for Table Read from ROM
1. Write an array to program ROM by
using the db directive.
2. Specify the table pointer (TBLPTR)
from which data is read.
3. Perform a tblrd instruction.
4. The data read is stored in the table
latch 61 Tutorial 7 Q1
• Assume that the program memory
space starting from 0x000500 store your
student ID number. Each digit of your
student ID number is stored in a byte.
Write a program to copy the content
from the program memory to the data
memory starting from 0x040. 62 63 64...
View Full Document
This document was uploaded on 11/07/2013.
- Fall '13