Branch Instructions
Notes
- Section 2.7
-
CBZ register, label and CBNZ register, label
- If R[register] ==/≠ 0, pc = pc + label
- Note, these are CB type instructions
- 8 bit opcode (26-31):
- CBNZ 5A8-5AF (101 1010 1xxx)
- CBZ: 5A0-5A7 (101 1010 0xxx)
- register is 0-4
- Label must fit into 19 bits (5 - 23)
- -218 to 218-1
- -262,144 to 262,143
- I didn't find it in P&H yet, but I am sure that these addresses are word addresses, not byte addresses.
- I am confident that instructions must be word aligned
- So, the effective reach of the branch address is somewhat larger, as all words end in 00 (hex) (ie +/-21 bytes of memory)
- This is called pc-relative branching
- B.cond
- A second type of branch is a B.cond
- For pipelining, the LEG8 has two sets of some math instructions
- ADD, ADDS for example
- The *S version sets flags.
- Negative (N)
- Zero (Z)
- Overflow (V)
- Carry (C)
-
B.cond address
- This is a cb type instruction, so it is pc relative
- The rt field is used to encode the condition
- EQ : z = 1, 00000
- NE : z = 0, 00001
- ...
- A table is given on page 98, I bet we see more of this later.
- B (branch)
-
B label
- This is an unconditional branch to the label.
- The instruction type is B
- 26-31 is the op-code (0A0 - 0BF) 000 1010 0000 to 000 1011 1111 or 00010xxxxxxx
- 0 to 25 is the branch address, 26 bits,
- But remember, word addressing
- Signed, and pc relative.
- BR (branch register)
- For larger branches
- This is an r type instruction
- RT is used to hold the register, why?
- pc = R[rt]
- Full range of 264 address, plus
- This is the return from subroutine instruction.
- This is an absolute branch.
- BL (branch and link)
- This is a b type instruction
- The additional action is that the PC+4 is stored in x30
- Why PC+4?
- PC relative again.