Early Chapter 2
Notes
- This is strange for me, you know quite a bit of this chapter
- But we need to look at the ARM/LEG specific portions.
- Word size
- The word size on the ARM architecture is 32 bits,
- But the machines we are using are 64 bits.
- 64 bits is a double word.
- Note, the ARM 8 can operate in 32 or 64 bit mode.
- Design Priciples:
- In this chapter they give us some design priciples
- The first Design Principle 1: Simplicity favors regularity
- You see this by looking at Figure 2.1 page 64-65
- Almost all of the instructions they present are
-
opcode destination source1, source2
- I don't know ARM well enough to know that this is completely true
- Remember the assembler may support pseudo ops
- Or things in assembly that do not exist in machine code.
- So, for example, the
mov dest src instruction is not a machine instruction. (see below)
- Registers
- The ARM/LEG architecture has 32 general purpose registers
- X0-X31
- But x31 is the zero register
- also called xzr
- It is always 0
- You can copy anything into it and it stays 0
- You can read from it, but it is always 0
- Why?
- We often need a source of zeros
- Also, we may be able to eliminate instructions
- Consider
mov rd rs
- With a zero register, is this needed?
-
add rd, rs, xzr
- What other instructions might we be able to eliminate?
- Any comparison to zero, which we do quite a bit
- We will see more as time goes by.
- Design Principal 2: Smaller is faster
- In this case we are trying to reduce the number of op-codes needed.
- How can this make things faster, we will see!
- Patterson said in a paper "Dedicating a register to zero is surprisingly a large factor in simplifying the RISC-V ISA"
- ARM Added the zero register in the 64 bit version.
- See the table on page 109 for usage
- x0-x7 are for parameters, scratch
- x8 is for the assembler/compiler
- x9-x15 are temporaries, scratch
- x16-x18 are either temps or can be used by assembler/compiler, scratch
- x19-27 are preserved
- x28 is also sp, the stack pointer.
- x29 is the fp
- x30 is the link register
- x31 is also xzr, the zero register.