English
Language : 

UPSD3212A Datasheet, PDF (21/163 Pages) STMicroelectronics – Flash Programmable System Devices with 8032 MCU with USB and Programmable Logic
uPSD3212A, uPSD3212C, uPSD3212CV
First, pointers R1 and R0 are set up to point to the
two bytes containing the last four BCD digits. Then
a loop is executed which leaves the last byte, loca-
tion 2EH, holding the last two digits of the shifted
number. The pointers are decremented, and the
loop is repeated for location 2DH. The CJNE in-
struction (Compare and Jump if Not equal) is a
loop control that will be described later. The loop
executed from LOOP to CJNE for R1 = 2EH, 2DH,
2CH, and 2BH. At that point the digit that was orig-
inally shifted out on the right has propagated to lo-
cation 2AH. Since that location should be left with
0s, the lost digit is moved to the Accumulator.
Table 7. Shifting a BCD Number Two Digits to
the Right (using direct MOVs: 14 bytes)
2A 2B 2C 2D 2E ACC
MOV A,2Eh 00 12 34 56 78 78
MOV 2Eh,2Dh 00 12 34 56 56 78
MOV 2Dh,2Ch 00 12 34 34 56 78
MOV 2Ch,2Bh 00 12 12 34 56 78
MOV 2Bh,#0 00 00 12 34 56 78
Table 8. Shifting a BCD Number Two Digits to
the Right (using direct XCHs: 9 bytes)
2A 2B 2C 2D 2E ACC
CLR A
00 12 34 56 78 00
XCH A,2Bh 00 00 34 56 78 12
XCH A,2Ch 00 00 12 56 78 34
XCH A,2Dh 00 00 12 34 78 56
XCH A,2Eh 00 00 12 34 56 78
Table 9. Shifting a BCD Number One Digit to the Right
2A
2B
2C
2D
2E
ACC
MOV
R1,#2Eh
00
12
34
56
78
xx
MOV
R0,#2Dh
00
12
34
56
78
xx
LOOP:
; loop for R1 = 2Eh
MOV
A,@R1
XCHD
A,@R0
SWAP
A
MOV
@R1,A
DEC
R1
DEC
R0
CNJE
R1,#2Ah,LOOP
00
12
34
56
78
78
00
12
34
58
78
76
00
12
34
58
78
67
00
12
34
58
67
67
00
12
34
58
67
67
00
12
34
58
67
67
00
12
34
58
67
67
; loop for R1 = 2Dh
; loop for R1 = 2Ch
; loop for R1 = 2Bh
00
12
38
45
67
45
00
18
23
45
67
23
08
01
23
45
67
01
CLR
XCH
A
A,2Ah
08
01
23
45
67
00
00
01
23
45
67
08
21/163