SN8P1829
8-Bit MCU build-in 12-bit ADC + PGIA + Charge-pump Reg 128 dots LCD driver
SONiX TECHNOLOGY CO., LTD
Page 16
Version 1.0
CHECKSUM CALCULATION
The ROM addresses 0004H~0007H and last address are reserved area. User should avoid these addresses
(0004H~0007H and last address) when calculate the Checksum value.
Example:
The demo program shows how to avoid 0004H~0007H when calculated Checksum from 00H to the end of
user’s code
MOV
A,
#END_USER_CODE$L
B0MOV
END_ADDR1,A
; save low end address to end_addr1
MOV
A,#END_USER_CODE$M
B0MOV
END_ADDR2,A
; save middle end address to end_addr2
CLR
Y
; set Y to 00H
CLR
Z
; set Z to 00H
@@:
CALL
YZ_CHECK
; call function of check yz value
MOVC
;
B0BSET
FC
;clear
C
flag
ADD
DATA1,A
;add A to Data1
MOV
A,R
ADC
DATA2,A
;add R to Data2
JMP
END_CHECK
;check if the YZ address = the end of code
AAA:
INCMS
Z
;Z=Z+1
JMP
@B
;if Z!= 00H calculate to next address
JMP
Y_ADD_1
;if Z=00H increase Y
END_CHECK:
MOV
A,END_ADDR1
CMPRS
A,Z
;check if Z = low end address
JMP
AAA
;if Not jump to checksum calculate
MOV
A,END_ADDR2
CMPRS
A,Y
;if Yes, check if Y = middle end address
JMP
AAA
;if Not jump to checksum calculate
JMP
CHECKSUM_END
;if Yes checksum calculated is done.
YZ_CHECK:
;check if YZ=0004H
MOV
A,#04H
CMPRS
A,Z
;check if Z=04H
RET
;if Not return to checksum calculate
MOV
A,#00H
CMPRS
A,Y
;if Yes, check if Y=00H
RET
;if Not return to checksum calculate
INCMS
Z
;if Yes, increase 4 to Z
INCMS
Z
INCMS
Z
INCMS
Z
RET
;set YZ=0008H then return
Y_ADD_1:
INCMS
Y
;increase
Y
NOP
JMP
@B
;jump to checksum calculate
CHECKSUM_END:
……….
……….
END_USER_CODE:
; Label of program end