Docsity

Data Processing Instructions - Introduction to Microprocessor Systems - Lecture Sli, Lecture notes of Computer Science

Partial preview of the text

Download Data Processing Instructions - Introduction to Microprocessor Systems - Lecture Sli and more Lecture notes Computer Science in PDF only on Docsity!

  • Data Processing Instructions
    • Shifter operands
    • Conditional execution and flags updates
    • Special cases with PC as destination
  • Memory Addressing Models and Modes
  • Memory Allocation
    • Allocation directives, alignment
  • ARM7TDMI Load/Store Instructions
    • Addressing modes

Topics

“Complexity is our friend.”

Data Processing Instructions

  • The data processing instructions all use a

shifter operand

  • Mnemonic{cond}{S} Rd, Rn, <shifter_operand>
  • In general, Rd  Rn operation shifter_operand
    • The non-destructive instructions will not use a destination register (Rd).
    • Some instructions reverse the operand order
    • MOV is a data processing instruction without Rn
  • Since shifts can be part of any data processing

instruction, there are no dedicated shift

instructions. Docsity.com

Shifter Operands

  • Immediate (I=1)
    • 8-bit value, 4-bit rotate code
    • Signified by #
  • Register
    • No shift
  • Shifted Register
    • LSL, LSR, ASR, ROR
    • Shift count from immediate or register
  • Rotate Right with Extend
    • Rotates register right 1 bit through CARRY flag

Conditional Execution and Flags

  • If a condition is used, the instruction will only

be executed if the condition is true.

  • Flags are only updated if S is used
    • Some instructions (B, BL, CMP, CMN, TST, TEQ, etc.) don’t use S
  • Using flags and conditions – what does this

do?

MOVS R1, R MOV R0, # MOVEQ R0, # MOVMI R0, #-1 Docsity.com

Specialized Moves

  • MVN – move negated
    • Shifter operand is complemented
    • Note that this is a 1’s-complement (NOT)
  • MRS – move CPSR/SPSR to GP register
  • MSR – move GP register to CPSR/SPSR

Data Processing - Logical

  • AND – bit-wise AND
  • BIC – bit clear (bit-wise AND with complement

of shifter operand)

  • EOR – bit-wise exclusive-OR
  • ORR – bit-wise inclusive-OR
  • TEQ – test equivalence (non-destructive XOR)
  • TST – test (non-destructive AND)

Multiply-Accumulate

  • 32x32 multiplies - 32-bit result
    • MLA – multiply-accumulate
    • MUL – multiply
  • 32x32 multiplies - 64-bit result
    • SMLAL – signed long multiply-accumulate
    • SMULL – signed long multiply
    • UMLAL – unsigned long multiply-accumulate
    • UMULL – unsigned long multiply MLA instructions do MAC operation: Ry (Ra*Rb) + Rc

Memory Addressing Models

  • Linear Memory Addressing
    • Instructions/registers can specify the complete address
  • Segmented Memory Addressing
    • Instructions/registers do not contain the full address, just part of it (the offset )
    • The remainder of the address is furnished by a page register or a segment register - There may be multiple segment registers
    • The full physical address is formed by combining the segment/page register and the offset from the instruction/register
    • Advantages / disadvantages

Memory Addressing Modes (cont)

  • Register Indirect Addressing
    • The instruction specifies a register that contains the memory address to access
    • May also support updating the register as part of the instruction (auto-increment and - decrement, pre- or post-, etc.)
  • Memory Indirect Addressing
    • A memory location (encoded in the instruction) contains the address to transfer to/from

Memory Addressing Modes (cont)

  • Indexed Addressing
    • The physical address is calculated from a constant base address (encoded in the instruction) and the contents of a register
    • Typically used for accessing data in arrays
      • Base address = array starting address
      • Register holds (element index × element size)
        • If byte array, element size = 1
        • If halfword array, element size = 2
        • If word array, element size = 4
      • The processor may do the index * element size calculation automatically Docsity.com

Memory Addressing Modes (cont)

  • PC-Relative Addressing
    • The address is computed by adding an offset value encoded in the instruction to the current value of the program counter.
    • In many microprocessors, the PC is not part of the programmer’s model, so PC-relative addressing is considered distinct from indexed or based addressing.
    • The ARM will use PC-relative addressing to implement the appearance of direct addressing. - Distance from the instruction to the label must be known at assembly-time.

ARM7TDMI Memory Allocation

  • Memory operands
    • Stored in little-endian format
  • Data allocation directives
    • DCB, DCW, DCD, SPACE, ALIGN
    • Identifiers and initializers
    • Constants vs. variables
    • Arrays and strings
  • Setting up a data area
    • Read-write AREAs are all linked into SRAM
  • Variable naming

ARM7 Load/Store Instructions

  • LDR/STR
    • Load and store a 32-bit register
      • Does not matter if signed or unsigned
    • Address should be word-aligned, or rotated version of the next lower aligned word is loaded
  • LDRB/STRB
    • Load and store an unsigned byte
    • On load, the value is sign-extended to 32-bits
    • Stores only access a single byte of memory

ARM7 Load/Store Addressing

  • Base register +/- immediate offset
    • Address = (Rn) +/- offset_
    • Syntax: [Rn, +/-#]
  • Base register +/- register offset
    • Address = (Rn) +/- (Rm)
    • Syntax: [Rn, +/-Rm]
  • Base register +/- shifted register offset
    • Address = (Rn) +/- (shifted Rm)
    • Shift modes with immediate shift count
      • LSL, LSR, ASR, ROR, RRX
    • Syntax: [Rn, +/-Rm, shift_mode #count]
  • Rn is unaffected by these addressing modes