Professional Documents
Culture Documents
Chapter 6 MZB
Chapter 6 MZB
Architecture
masked off masked ON MVN (MoVe and Not), performs a bitwise NOT on the second source (an
immediate or register) and writes the result to the destination register.
Slides prepared by: DMZB
Data-processing instructions
• ARM shift operations are LSL (logical shift left), LSR (logical shift right),
ASR (arithmetic shift right), and ROR (rotate right)
• MUL R1, R2, R3 multiplies the values in R2 and R3 and places the least significant bits of the product in R1;
• UMULL (unsigned multiply long) and SMULL (signed multiply long) multiply two 32-bit numbers and
• UMULL R1, R2, R3, R4 performs an unsigned multiply of R3 and R4. The least significant 32 bits of the
product is placed in R1 and the most significant 32 bits are placed in R2.
• Each of these instructions also has a multiply-accumulate variant, MLA, SMLAL, and UMLAL, that adds the
product to a running 32- or 64-bit sum. These instructions can boost the math performance in applications
such as matrix multiplication and signal processing consisting of repeated multiplies and adds.
Slides prepared by: DMZB
Programming
• Data-processing instructions (often called logical and arithmetic instructions in other
architectures)
• Logical Instructions
• Shift Instructions
• Multiply Instructions
• Condition Flags
• Branching
• Conditional Statements
• Loops
• Memory
• Functions
• overflow flag indicates that sign bit has been changed during adding or subtracting operations.
• carry flag means adding or subtracting two registers has carry or borrow bit.
Instead of the LSL and LDR instruction sequence in Code Example 6.18, we can use a single instruction:
LDR R3, [R0, R1, LSL #2]
R1 is scaled (shifted left by two) then added to the base address (R0). Thus, the memory address is R0 + (R1 × 4)
In each case, the base register is R1 and the offset is R2. The offset can be subtracted by writing –R2.
The offset may also be an immediate in the range of 0–4095 that can be added (e.g., #20) or
subtracted (e.g., #-20)
reference: https://www.youtube.com/watch?v=H4xoaOlNSJo
Slides prepared by: DMZB
Functions
• ARM divides registers into preserved and non-preserved categories.
The preserved registers include R4–R11. The non-preserved registers
are R0–R3 and R12. SP and LR (R13 and R14) must also be preserved.
• Function must save and restore any of the preserved registers that it
wishes to use, but it can change the nonpreserved registers freely.