SN8P2604
8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 19
Version 1.1
Example: Modify above example by “INC_YZ” macro.
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
INC_YZ
; Increment the index address for next address.
;
@@:
MOVC
; To lookup data, R = 51H, ACC = 05H.
…
;
ORG
0x0100
; Set TABLE1 start address is 0x0100 to avoid “B0MOV M, I”
instruction doesn’t support “I=0xE6” and “I=0xE7”.
TABLE1:
DW
0035H
; To define a word (16 bits) data.
DW
5105H
DW
2012H
…
The other example of loop-up table is to add Y or Z index register by accumulator. Please be careful if “carry” happen.
Example: Increase Y and Z register by B0ADD/ADD instruction.
B0MOV
Y, #TABLE1$M
; To set lookup table’s middle address.
B0MOV
Z, #TABLE1$L
; To set lookup table’s low address.
B0MOV
A, BUF
; Z = Z + BUF.
B0ADD Z,
A
B0BTS1
FC
; Check the carry flag.
JMP
GETDATA
; FC = 0
INCMS
Y
; FC = 1. Y+1.
NOP
GETDATA:
;
MOVC
; To lookup data. If BUF = 0, data is 0x0035
; If BUF = 1, data is 0x5105
; If BUF = 2, data is 0x2012
…
ORG
0x0100
; Set TABLE1 start address is 0x0100 to avoid “B0MOV M, I”
instruction doesn’t support “I=0xE6” and “I=0xE7”.
TABLE1:
DW
0035H
; To define a word (16 bits) data.
DW
5105H
DW
2012H
…