ARM Instruction Sets, Summaries of Logic

shift=direction #integer, where direction is LSL for left shift or LSR for right shift, and integer is a 5-bit unsigned number specifying the shift format.

Typology: Summaries

2022/2023

Uploaded on 02/28/2023

alley
alley šŸ‡ŗšŸ‡ø

4.2

(5)

256 documents

1 / 30

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Jin-Fu Li
Department of Electrical Engineering
National Central University
Jungli, Taiwan
Chapter 4
Chapter 4
ARM Instruction Sets
ARM Instruction Sets
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download ARM Instruction Sets and more Summaries Logic in PDF only on Docsity!

Jin-Fu Li

Department of Electrical Engineering

National Central University

Jungli, Taiwan

Chapter 4

Chapter 4

ARM Instruction Sets

ARM Instruction Sets

Jin-Fu Li, EE, NCU

¾

Registers, Memory Access, and Data Transfer

¾

Arithmetic and Logic Instructions

¾

Branch Instructions

¾

Assembly Language

¾

I/O Operations

¾

Subroutines

¾

Program Examples

Outline

Jin-Fu Li, EE, NCU

ARM Processor

¾

ARM processor was designed by Advanced RISCMachine (ARM) Limited Company

¾

ARM processors are major used for low-power and lowcost applications Ā‹

Mobile phones

Communication modems

Automotive engine management systems

Hand-held digital systems

¾

This chapter introduces the ARM instruction sets basedon the ARM7 processor Ā‹

Different versions of ARM processors share the same basicmachine instruction sets

Jin-Fu Li, EE, NCU

Registers and Memory Access

¾

In the ARM architecture Ā‹

Memory is byte addressable

32-bit addresses

32-bit processor registers

¾

Two operand lengths are used in moving data betweenthe memory and the processor registers Ā‹

Bytes (8 bits) and words (32 bits)

¾

Word addresses must be aligned, i.e., they must bemultiple of 4 Ā‹

Both little-endian and big-endian memory addressing aresupported

¾

When a byte is loaded from memory into a processorregister or stored from a register into the memory Ā‹

It always located in the low-order byte position of the register

Jin-Fu Li, EE, NCU

Register Structure

¾

The use of processor mode bits and interrupt disable bitswill be described in conjunction with input/outputoperations and interrupts in Chapter 5

¾

There are 15 additional general-purpose registers calledthe banked registers Ā‹

They are duplicates of some of the R0 to R14 registers

They are used when the processor switches into Supervisor orInterrupt modes of operation

¾

Saved copies of the Status register are also available in theSupervisor and Interrupt modes

¾

The banked registers and Status register copies will alsobe discussed in Chapter 5

Jin-Fu Li, EE, NCU

ARM Instruction Format

¾

Each instruction is encoded into a 32-bit word

¾

Access to memory is provided only by Load and Storeinstructions

¾

The basic encoding format for the instructions, such asLoad, Store, Move, Arithmetic, and Logic instructions, isshown below

¾

An instruction specifies a conditional execution code(Condition), the OP code, two or three registers (Rn, Rd,and Rm), and some other information

Condition

OP code

Rn

Rd

Rm

Other info

Jin-Fu Li, EE, NCU

Memory Addressing Modes

¾

Pre-indexed mode Ā‹

The effective address of the operand is the sum of the contents ofthe base register Rn and an offset value

¾

Pre-indexed with writeback mode Ā‹

The effective address of the operand is generated in the same wayas in the Pre-indexed mode, and then the effective address iswritten back into Rn

¾

Post-indexed mode Ā‹

The effective address of the operand is the contents of Rn. Theoffset is then added to this address and the result is written backinto Rn

Jin-Fu Li, EE, NCU

ARM Indexed Addressing Modes

With immediate offset:

Pre-indexedPre-indexed with writebackPost-indexed

With offset in Rn

Pre-indexedPre-indexed with writebackPost-indexed

Relative (Pre-indexed withImmediate offset)

Name

Assembler syntax

Addressing function

[Rn, #offset][Rn, #offset]![Rn], #offest[Rn, +Rm, shift][Rn, +Rm, shift]![Rn], +Rm, shiftLocation

EA=[Rn]+offsetEA=[Rn]+offset; Rn

ƅ

[Rn]+offset

EA=[Rn]; Rn

ƅ

[Rn]+offset

EA=[Rn]+[Rm] shiftedEA=[Rn]+[Rm] shifted;Rn

ƅ

[Rn]+[Rm] shifted

EA=[Rn];Rn

ƅ

[Rn]+[Rm] shifted

EA=Location=[PC]+offset

shift=direction #integer, where direction is LSL for left shift or LSR for right shift, and integeris a 5-bit unsigned number specifying the shift format+ Rm=the offset magnitude in register Rm can be added to or subtracted from the contentsof based register Rn

Jin-Fu Li, EE, NCU

Pre-Indexed Addressing Mode

STR

R3, [R5,R6]

Operand

200=offset

R

Based register

R

Offset register

Jin-Fu Li, EE, NCU

Post-Indexed Addressing with Writeback

100=25x

R

Based register

R

Offset register

100=25x

Load instruction:LDR R1, [R2], R10, LSL, #

Jin-Fu Li, EE, NCU

Load/Store Multiple Operands

¾

In ARM processors, there are two instructions for loadingand storing multiple operands Ā‹

They are called Block transfer instructions

¾

Any subset of the general purpose registers can be loadedor stored Ā‹

Only word operands are allowed, and the OP codes used areLDM (Load Multiple) and STM (Store Multiple)

¾

The memory operands must be in successive wordlocations

¾

All of the forms of pre- and post-indexing with andwithout writeback are available

¾

They operate on a Base register Rn specified in theinstruction and offset is always 4 Ā‹

LDMIA R10!, {R0,R1,R6,R7}

IA: ā€œIncrement Afterā€ corresponding to post-indexing

Jin-Fu Li, EE, NCU

Arithmetic Instructions

¾

The basic expression for arithmetic instructions is Ā‹

OPcode Rd, Rn, Rm

¾

For example, ADD R0, R2, R4 Ā‹

Performs the operation R

ƅ

[R2]+[R4]

¾

SUB R0, R6, R5 Ā‹

Performs the operation R

ƅ

[R6]-[R5]

¾

Immediate mode: ADD R0, R3, #17 Ā‹

Performs the operation R

ƅ

[R3]+

¾

The second operand can be shifted or rotated before beingused in the operation Ā‹

For example, ADD R0, R1, R5, LSL #4 operates as follows: thesecond operand stored in R5 is shifted left 4-bit positions(equivalent to [R5]x16), and its is then added to the contents ofR1; the sum is placed in R

Jin-Fu Li, EE, NCU

Branch Instructions

¾

Conditional branch instructions contain a signed 24-bitoffset that is added to the updated contents of theProgram Counter to generate the branch target address

¾

The format for the branch instructions is shown as below Ā‹

Offset is a signed 24-bit number. It is shifted left two-bit positions(all branch targets are aligned word addresses), signed extendedto 32 bits, and added to the updated PC to generate the branchtarget address

The updated points to the instruction that is two words (8 bytes)forward from the branch instruction

Condition

OP code

offset

Jin-Fu Li, EE, NCU

ARM Branch Instructions

¾

The BEQ instruction (Branch if Equal to 0) causes abranch if the Z flag is set to 1

BEQ LOCATION

Branch target instruction

Updated [PC]=

LOCATION=

Offset=