SN8P275X Series
8-bit micro-controller build-in 12-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 19
Version 0.7
2.1.1.3
LOOK-UP TABLE DESCRIPTION
In the ROM’s data lookup function, X register is pointed to high byte address (bit 16~bit 23), Y register is pointed to
middle byte address (bit 8~bit 15) and Z register is pointed to low byte address (bit 0~bit 7) of ROM. After MOVC
instruction executed, the low-byte data will be stored in ACC and high-byte data stored in R register.
¾
Example: To look up the ROM data located “TABLE1”.
B0MOV
X, #TABLE1$H
; To set lookup table1’s high address
B0MOV
Y, #TABLE1$M
; To set lookup table1’s middle address
B0MOV
Z, #TABLE1$L
; To set lookup table1’s low address.
MOVC
; To lookup data, R = 00H, ACC = 35H
; Increment the index address for next address.
INCMS Z
;
Z+1
JMP
@F
; Z is not overflow.
INCMS
Y
; Z is overflow, Y=Y+1.
JMP
@F
; Y is not overflow.
INCMS
X
; Y is overflow, X=X+1.
NOP
;
@@:
MOVC
; To lookup data, R = 51H, ACC = 05H.
…
;
TABLE1:
DW
0035H
; To define a word (16 bits) data.
DW
5105H
DW
2012H
…
Note:
The X, Y registers will not increase automatically when Y, Z registers crosses boundary from 0xFF
to 0x00. Therefore, user must take care such situation to avoid loop-up table errors. If Z register is
overflow, Y register must be added one. If Y register is overflow, X register must be added one. The
following INC_XYZ macro shows a simple method to process X, Y and Z registers automatically.
¾
Example: INC_XYZ macro.
INC_XYZ
MACRO
INCMS
Z
; Z+1
JMP
@F
; Not overflow
INCMS
Y
; Y+1
JMP
@F
; Not overflow
INCMS
X
; X+1
NOP
; Not overflow
@@:
ENDM