whoops double headings
[libreriscv.git] / openpower / isa / branch.mdwn
1 # Branch
2
3 I-Form
4
5 * b target_addr (AA=0 LK=0)
6 * ba target_addr (AA=1 LK=0)
7 * bl target_addr (AA=0 LK=1)
8 * bla target_addr (AA=1 LK=1)
9
10 Pseudo-code:
11
12 if AA then NIA <-iea EXTS(LI || 0b00)
13 else NIA <-iea CIA + EXTS(LI || 0b00)
14 if LK then LR <-iea CIA + 4
15
16 Special Registers Altered:
17
18 LR (if LK=1)
19
20 # Branch Conditional
21
22 B-Form
23
24 * bc BO,BI,target_addr (AA=0 LK=0)
25 * bca BO,BI,target_addr (AA=1 LK=0)
26 * bcl BO,BI,target_addr (AA=0 LK=1)
27 * bcla BO,BI,target_addr (AA=1 LK=1)
28
29 Pseudo-code:
30
31 if (mode_is_64bit) then M <- 0
32 else M <- 32
33 if ¬BO[2] then CTR <- CTR - 1
34 ctr_ok <- BO[2] | ((CTR[M:63] != 0) ^ BO[3])
35 cond_ok <- BO[0] | ¬(CR[BI+32] ^ BO[1])
36 if ctr_ok & cond_ok then
37 if AA then NIA <-iea EXTS(BD || 0b00)
38 else NIA <-iea CIA + EXTS(BD || 0b00)
39 if LK then LR <-iea CIA + 4
40
41 Special Registers Altered:
42
43 CTR (if BO2=0)
44 LR (if LK=1)
45
46 # Branch Conditional to Link Register
47
48 XL-Form
49
50 * bclr BO,BI,BH (LK=0)
51 * bclrl BO,BI,BH (LK=1)
52
53 Pseudo-code:
54
55 if (mode_is_64bit) then M <- 0
56 else M <- 32
57 if ¬BO[2] then CTR <- CTR - 1
58 ctr_ok <- BO[2] | ((CTR[M:63] != 0) ^ BO[3])
59 cond_ok <- BO[0] | ¬(CR[BI+32] ^ BO[1])
60 if ctr_ok & cond_ok then NIA <-iea LR[0:61] || 0b00
61 if LK then LR <-iea CIA + 4
62
63 Special Registers Altered:
64
65 CTR (if BO2=0)
66 LR (if LK=1)
67
68 # Branch Conditional to Count Register
69
70 XL-Form
71
72 * bcctr BO,BI,BH (LK=0)
73 * bcctrl BO,BI,BH (LK=1)
74
75 Pseudo-code:
76
77 cond_ok <- BO[0] | ¬(CR[BI+32] ^ BO[1])
78 if cond_ok then NIA <-iea CTR[0:61] || 0b00
79 if LK then LR <-iea CIA + 4
80
81 Special Registers Altered:
82
83 LR (if LK=1)
84
85 # Branch Conditional to Branch Target Address Register
86
87 XL-Form
88
89 * bctar BO,BI,BH (LK=0)
90 * bctarl BO,BI,BH (LK=1)
91
92 Pseudo-code:
93
94 if (mode_is_64bit) then M <- 0
95 else M <- 32
96 if ¬BO[2] then CTR <- CTR - 1
97 ctr_ok <- BO[2] | ((CTR[M:63] != 0) ^ BO[3])
98 cond_ok <- BO[0] | ¬(CR[BI+32] ^ BO[1])
99 if ctr_ok & cond_ok then NIA <-iea TAR[0:61] || 0b00
100 if LK then LR <-iea CIA + 4
101
102 Special Registers Altered:
103
104 CTR (if BO2=0)
105 LR (if LK=1)