background image

I

NTRODUCTION TO THE

ARM

®

P

ROCESSOR

U

SING

I

NTEL

FPGA T

OOLCHAIN

For Quartus Prime 16.1

adds 1 to the contents of R1 and places the sum into R0. The constant

value

can be specified as a decimal number,

as in this example, or as a binary value #0b1, or as a hexadecimal value #0x1. Valid constants include any eight-bit
value, such as 0xFF. The eight-bit value can also be produced by rotation in a 32-bit word—for example, other valid
constants include 0xFF000000, 0xFF0000, and 0xFF00. In general, the constant can be any value which can be
generated by rotating a byte to the right any

even

number of times (0, 2,

. . .

, 30) in a 32-bit word (see the

ARM

Assembler Reference

for more details).

Alternatively,

Operand2

can be given as a register R

m

, as in

OP

R

d

, R

n

, R

m

This instruction performs the operation

OP

using the contents of R

n

and R

m

, and places the result into R

d

. For

example

ADD R0, R1, R2

adds the contents of R1 and R2, and places the sum into R0.

When

Operand2

is a register, R

m

can either be used directly, as in the above example, or else its value can be shifted

before being used. If it is shifted, then the shifting amount can be specified as a five-bit constant, as in

OP R

d

, R

n

, R

m

, LSL #3

or as the least-significant byte of a register R

s

, as in

OP R

d

, R

n

, R

m

, LSL R

s

In these examples LSL means

Logical Shift Left

. Other examples of shift variants include right-shift, and rotate

operations, as discussed in section

6.7

.

6.3.1

Using Condition Code Flags

The data processing instructions can optionally affect the ARM condition code flags, or can be executed conditionally
based on the values of the condition code flags. These options are expressed in the general form

OP{S}{cond}

R

d

, R

n

,

Operand2

If

S

is included in the instruction mnemonic, as in ADDS, then the condition code flags will be set depending on the

results of the instruction. But if

S

is not included, as in ADD, then the flags are unaffected by the instruction. Setting

of the condition code flags is discussed further in Section

6.9

.

An optional

cond

appended to an instruction mnemonic allows an instruction to be either executed or skipped,

depending on the current values of the condition code flags. This concept is discussed in Section

6.10

.

10

Intel Corporation - FPGA University Program

November 2016

Summary of Contents for ARM Cortex-A9

Page 1: ...an ARM based system on Intel s DE1 SOC board A full description of ARM processors is provided in the ARM Architecture Reference Manual which is available on the ARM Holdings web site Contents Overvie...

Page 2: ...ral purpose registers R0 to R14 a Program Counter R15 and a Current Program Status Register CPSR as shown in Figure 1 All general purpose registers can be used in the same way However software program...

Page 3: ...s called banked registers for saving the contents of primary registers when various types of interrupts occur as discussed in Section 10 4 Instruction Sets The ARM Cortex A9 processor can execute inst...

Page 4: ...base register and a value that is either given as a signed 12 bit offset directly in the instruction or as a magnitude in the index register The magnitude in Rm can be scaled by shifting it either lef...

Page 5: ...hift Address Rn Rn Rn Rm shifted offset a signed number given in the instruction shift direction integer where direction is LSL for left shift or LSR for right shift and integer is a 5 bit unsigned nu...

Page 6: ...will determine the immediate offset as the difference between the address MEMLOC and the contents of the updated Program Counter It will generate the instruction LDR R2 R15 offset This offset takes in...

Page 7: ...emory and I 0 interfaces and the general purpose registers The LDR Load Register instruction illustrated in the previous section loads a 32 bit operand into a register The corresponding Store instruct...

Page 8: ...o not have to be contiguous A range of registers is specified by listing the first and the last registers in the range separated by a dash In the resulting machine instruction each register is identif...

Page 9: ...B SP R1 R3 R5 The instruction POP R1 R3 R5 restores the contents of these registers from the stack The equivalent Load Multiple instruction would be LDMIA SP R1 R3 R5 6 2 Data Processing Instructions...

Page 10: ...its value can be shifted before being used If it is shifted then the shifting amount can be specified as a five bit constant as in OP Rd Rn Rm LSL 3 or as the least significant byte of a register Rs...

Page 11: ...in ADD R0 R1 24 The Assembler will implement this operation with the Subtract instruction SUB R0 R1 24 6 4 1 Multiplication There are two versions of multiplication instructions MUL Multiply MLA Mult...

Page 12: ...uctions that perform logic operations for testing purposes The Test instruction TST Rn Operand2 performs the AND operation using the contents of Rn and Operand2 and sets the condition code flags based...

Page 13: ...sing mode to access the literal pool The Assembler decides where in memory to place the literal pool typically it is immediately following the program s machine code A constant may be represented by a...

Page 14: ...wo registers or the contents of a register and an immediate value and set the condition code flags based on the result The Compare instruction CMP Rn Operand2 performs the comparison by subtracting th...

Page 15: ...f data processing instructions is OP S cond Rd Rn Operand2 The conditions that can be specified are those in Table 2 Observe that there are 14 patterns for conditions that depend on the condition code...

Page 16: ...d operation of the ARM processor The branch instruction is executed conditionally based on the current setting of the Condition Code flags The conditions that can be specified are given in Table 2 For...

Page 17: ...that if nested subroutines are used it is necessary to save the contents of R14 typically on the stack prior to a nested subroutine call We should also mention that in the ARM environment there is a c...

Page 18: ...ymbol visible outside the assembled object file hword expressions Expressions separated by commas are specified Each expression is assembled into a 16 bit number include filename Provides a mechanism...

Page 19: ...st instruction in the program The execution of the program ends by continuously looping on this instruction text global _start _start LDR R0 AVECTOR Register R0 is a pointer to vector A LDR R1 BVECTOR...

Page 20: ...d by a program executing a Supervisor Call instruction SVC It is also entered on reset or power up Abort mode is entered if a program attempts to access a non existing memory location Undefined mode i...

Page 21: ...re efficient some other registers are involved These registers are shown in blue in Figure 4 They are called the banked registers There is a different set of banked registers for each exception mode A...

Page 22: ...service routine needs to use some of these registers the contents of the registers must be saved on the stack and later restored However having the five banked registers R8_fiq to R12_fiq in the FIQ m...

Page 23: ...anked saved status register that is accessed Thus MRS Rd SPSR copies the contents of SPSR_irq into register Rd 11 Exception Processing An exception in the normal flow of program execution can be cause...

Page 24: ...A software interrupt which is called a software exception in ARM literature occurs when an SVC instruction is encountered in a program This instruction causes the processor to switch into Supervisor m...

Page 25: ...e processor saves the contents of CPSR in the SPSR_irq register and it saves the contents of PC in the link register LR_irq It also sets the mode bits in CPSR to denote the IRQ exception mode and it s...

Page 26: ...d with the instruction SUBS PC LR 8 11 6 Nested Interrupts When two or more interrupts or exceptions occur at different priority levels causing the processor to enter different modes of operation thei...

Page 27: ...gure 5 illustrates the structure of the code that can be used text global _start LDR PC _start Go to the beginning of the MAIN program LDR PC SERVICE_UND Unimplemented instruction LDR PC SERVICE_SVC S...

Page 28: ...al to ensure that the cached data is not used instead of the current values in the I O device registers In effect the data cache has to be bypassed when reading or writing the registers in I O devices...

Page 29: ...ifications in accordance with Intel s stan dard warranty but reserves the right to make changes to any products and services at any time without notice Intel assumes no responsibility or liability ari...

Reviews: