5af6b669b88e284755c83863cc4619382e8b074f
[openpower-isa.git] / openpower / isa / bcd.mdwn
1 <!-- Instructions here described in PowerISA Version 3.0 B Book 1 -->
2
3 <!-- Section 3.3.15 Binary Coded Decimal (BCD) Assist Instructions. Page 111 -->
4
5 <!-- The Binary Coded Decimal Assist instructions operate on Binary Coded Decimal -->
6 <!-- operands (cbcdtd and addg6s) and Decimal Floating-Point operands (cdtbcd) -->
7 <!-- See Chapter 5. for additional information. -->
8
9
10 # Convert Declets To Binary Coded Decimal
11
12 X-Form
13
14 * cdtbcd RA, RS
15
16 Pseudo-code:
17
18 do i = 0 to 1
19 n <- i * 32
20 RA[n+0:n+7] <- 0
21 RA[n+8:n+19 ] <- DPD_TO_BCD ( (RS)[n+12:n+21] )
22 RA[n+20:n+31] <- DPD_TO_BCD ( (RS)[n+22:n+31] )
23
24 Special Registers Altered:
25
26 None
27
28 # Add and Generate Sixes
29
30 XO-Form
31
32 * addg6s RT,RA,RB
33
34 Pseudo-code:
35
36 dc <- [0]*16
37 do i = 0 to 15
38 temp <- (0b0 || RA[4*i:63]) + (0b0 || RB[4*i:63])
39 dc[i] <- temp[0]
40 c <- ([dc[0]]*4 || [dc[1]]*4 || [dc[2]]*4 || [dc[3]]*4 ||
41 [dc[4]]*4 || [dc[5]]*4 || [dc[6]]*4 || [dc[7]]*4 ||
42 [dc[8]]*4 || [dc[9]]*4 || [dc[10]]*4 || [dc[11]]*4 ||
43 [dc[12]]*4 || [dc[13]]*4 || [dc[14]]*4 || [dc[15]]*4)
44 RT <- (¬c) & 0x6666_6666_6666_6666
45
46 Special Registers Altered:
47
48 None
49
50 # Convert Binary Coded Decimal To Declets
51
52 X-Form
53
54 * cbcdtd RA, RS
55
56 Pseudo-code:
57
58 do i = 0 to 1
59 n <- i * 32
60 RA[n+0:n+11] <- 0
61 RA[n+12:n+21] <- BCD_TO_DPD ( (RS)[n+8:n+19] )
62 RA[n+22:n+31] <- BCD_TO_DPD ( (RS)[n+20:n+31] )
63
64 Special Registers Altered:
65
66 None
67
68 <!-- Checked March 2021 -->