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