Topics covered: ARM Instruction Set Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.

Slides:



Advertisements
Similar presentations
Instruction execution and sequencing
Advertisements

ARM versions ARM architecture has been extended over several versions.
Appendix D The ARM Processor
1 ARM Movement Instructions u MOV Rd, ; updates N, Z, C Rd = u MVN Rd, ; Rd = 0xF..F EOR.
INSTRUCTION SET ARCHITECTURES
Embedded System Design Center Sai Kumar Devulapalli ARM7TDMI Microprocessor Load and store instruction.
Introduction to Embedded Systems Intel Xscale® Assembly Language and C Lecture #3.
Topics covered: CPU Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
There are two types of addressing schemes:
Computer Organization and Architecture
ARM Microprocessor “MIPS for the Masses”.
Computer Organization and Architecture
Execution of an instruction
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Memory - Registers Instruction Sets
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
ARM 7 Datapath. Has “BIGEND” input bit, which defines whether the memory is big or little endian Modes: ARM7 supports six modes of operation: (1) User.
Part II: Addressing Modes
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
ARM Instructions I Prof. Taeweon Suh Computer Science Education Korea University.
Embedded System Design Center Sai Kumar Devulapalli ARM7TDMI Microprocessor Thumb Instruction Set.
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
Topic 10: Instruction Representation CSE 30: Computer Organization and Systems Programming Winter 2011 Prof. Ryan Kastner Dept. of Computer Science and.
Lecture 4. ARM Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University ECM586 Special Topics in Embedded Systems.
Chapter 3-1 ARM ISA ARM Instruction Set Architecture ARM Instruction Set Architecture Next Lecture Next Lecture  ARM program examples.
Chapter 2-2 Assembly Instructions Number Systems Number Systems Assembly Instructions Assembly Instructions Branch Branch Next Lecture Next Lecture  Addressing.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Execution of an instruction
Computer Architecture Lecture 03 Fasih ur Rehman.
Unit-2 Instruction Sets, CPUs
Topics covered: Instruction Set Architecture CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE Lecture 21 & 22 Processor Organization Register Organization Course Instructor: Engr. Aisha Danish.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
CPS 4150 Computer Organization Chapter 2-2 Fall 2006 Ching-Song Don Wei.
1 Pertemuan 9 Mesin ARM: I Matakuliah: T0324 / Arsitektur dan Organisasi Komputer Tahun: 2005 Versi: 1.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
Intel Xscale® Assembly Language and C. The Intel Xscale® Programmer’s Model (1) (We will not be using the Thumb instruction set.) Memory Formats –We will.
Lecture 6: Decision and Control CS 2011 Spring 2016, Dr. Rozier.
Intel Xscale® Assembly Language and C. The Intel Xscale® Programmer’s Model (1) (We will not be using the Thumb instruction set.) Memory Formats –We will.
Displacement (Indexed) Stack
Instruction sets : Addressing modes and Formats
Control Unit Lecture 6.
Assembly Language Programming of 8085
Introduction to the ARM Instruction Set
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
The Cortex-M3/m4 Embedded Systems: Cortex-M3/M4 Instruction Sets
Chapter 4 Addressing modes
Microcomputer Programming
William Stallings Computer Organization and Architecture 8th Edition
Instructions - Type and Format
Architecture CH006.
Chapter 8 Central Processing Unit
ECEG-3202 Computer Architecture and Organization
ARM Load/Store Instructions
The ARM Instruction Set
ARM Introduction.
Overheads for Computers as Components 2nd ed.
Computer Architecture
COMPUTER ORGANIZATION AND ARCHITECTURE
Introduction to Assembly Chapter 2
An Introduction to the ARM CORTEX M0+ Instructions
Presentation transcript:

Topics covered: ARM Instruction Set Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface

1 ARM Instruction Set Architecture  Register structure  Memory access  Addressing modes  Instructions  Assembly language  Subroutines  Simple programs in ARM assembly language

2 Register structure  Sixteen 32-bit registers labeled R0 through R15 :  15 general purpose registers ( R0 through R14 )  Program Counter ( PC ) register R15.  General purpose registers can hold data operands or memory addresses.  Current program status register (CPSR) or Status Register:  Condition code flags ( N, Z, C, V ),  Interrupt disable flags.  Processor mode bits.  15 additional general purpose registers called banked registers.  Duplicates of some of the R0 through R14.  Used when the processor switches into the Supervisor mode or Interrupt modes of operation.

3 Register structure (contd..) Program counter R0 R1 310 R Status 28 R15 (PC) 3064 CPSR N - Negative Z - Zero C - Carry V- Overflow Condition code flags Processor mode bits register Interrupt disable bits General purpose registers 15

4 Memory access  Memory is byte-addressable, using 32-bit addresses.  Two operand lengths are used in moving data between the memory and processor registers:  Bytes (8-bits) and Word (32-bits).  Word addresses must be aligned:  Multiples of 4.  Little-endian and big-endian addressing schemes are supported.  Determined by an external input control line.  When the length of the operand in a data transfer operation is a byte, the byte is stored in the low-order byte position of the register.

5 Addressing modes  Memory is addressed by generating the Effective Address (EA) of the operand by adding a signed offset to the contents of a base register Rn.  Pre-indexed mode:  EA is the sum of the contents of the base register Rn and an offset value.  Pre-indexed with writeback:  EA is generated the same way as pre-indexed mode.  EA is written back into Rn.  Post-indexed mode:  EA is the contents of Rn.  Offset is then added to this address and the result is written back to Rn.

6 Addressing modes (contd..)  Relative addressing mode:  Program Counter ( PC ) is used as a base register.  Pre-indexed addressing mode with immediate offset  No absolute addressing mode available in the ARM processor.  Offset is specified as:  Immediate value in the instruction itself.  Contents of a register specified in the instruction.

7 Instructions ARM architecture is a RISC architecture Each instruction is encoded into a 32-bit word. Condition 31 OP code RnRdOther infoRm Instruction format Instruction specifies a: - Conditional execution code. - OP Code. - Two or three registers (Rn, Rd, and Rm) - Other information. - If Rm is not needed, other information field extends to the last bit.

8 Instructions (contd..)  All instructions are conditionally executed, depending on a condition specified in the condition code of the instruction.  Instruction is executed only if the current state of the processor condition code flags satisfies the condition specified in the high-order 4 bits of the instruction.  One of the condition codes is used to indicate that an instruction is always executed.

9 Instructions (contd..) Memory access instructions Memory is accessed using LOAD and STORE instructions. Mnemonic for LOAD is LDR and STORE is STR. If a byte operand is desired, then mnemonics are LDRB and STRB Recall that the memory is accessed by generating the effective address (EA) of the operand using various addressing modes. Pre-indexed addressing mode (1): - Offset specified as an immediate value - LDR Rd, [Rn,#offset] Pre-indexed addressing mode(2): - Offset magnitude is specified in a register. - LDR Rd, [Rn,+Rm] - Contents of Rm specify the magnitude of the offset. - Rm is preceded by a minus sign if negative offset is desired.

10 Instructions (contd..) Memory access instructions Pre-indexed addressing mode with offset magnitude in a register = offset Base register 200 Offset register * * * * * * * * * LDR R3, [R5, R6]R5 R6 Operand EA = = 1200

11 Instructions (contd..) Memory access instructions Pre-indexed with writeback (1): - Offset is specified as an immediate value. - LDR Rd, [Rn,#offset]! - Exclamation mark indicates writeback, that is the effective address should be written back in Rn. Pre-indexed with writeback (2): - Offset magnitude is specified in a register. - LDR Rd, [Rn, +Rm]! - Exclamation mark indicates writeback, that is the effective address should be written back in Rn. Pre-index with writeback is a generalization of Autodecrement addressing mode.

12 Instructions (contd..) Memory access instructions Pre-indexed mode with writeback. Offset magnitude is specified in a register = offset Base register 200 Offset register * * * * * * * * * LDR R3, [R5, R6]!R5 R6 Operand EA = = 1200 R5 = 1200

13 Instructions (contd..) Memory access instructions Post-indexed (1): - Offset is specified as an immediate value. - LDR Rd, [Rn],#offset - Offset is added to Rn after the operand is accessed and the contents are stored in Rn. Post-indexed (2): - Offset magnitude is specified in a register. - LDR Rd,[Rn]+Rm - Offset is added to Rn after the operand is accessed and the contents are stored in Rn. Post-indexed addressing mode always involves writeback. It is a generalization of Autoincrement addressing mode.

14 Instructions (contd..) Memory access instructions Post-indexed addressing. Offset magnitude is specified in a register = offset Base register 200 Offset register * * * * * * * * * LDR R3, [R5] R6R5 R6 Operand EA = 1000 R5 = = 1200

15 Instructions (contd..) Memory access instructions When the offset is given in a register, it may be scaled by a power of 2 by shifting to the right or left. All the addressing modes, pre-indexed, pre-indexed with writeback and post-indexed. LDR R0,[R1,-R2,LSL#4]! Relative mode: - Only the address of a memory location is specified. - LDR R1, ITEM. - This would normally be Absolute addressing mode, but since there is no absolute addressing mode, the EA is computed as the offset of this memory location from the PC. - Operand must be within bytes relative to the updated PC. ( PC points to the location following the instruction)

16 Instructions (contd..) Memory access instructions Relative mode 52 = offset 1000 word (4 bytes) ITEM = 1060 Operand Memory address updated [PC] = 1008 * * * * * * LDR R1, ITEM PC points to the word after the instruction location. EA =

17 Instructions (contd..) Memory access instructions Block transfer instructions Instructions for loading and storing multiple operands. Any subset of the general purpose registers can be loaded/stored. Mnemonic for Load Multiple is LDM, Store Multiple is STM. Memory operands must be available in successive locations. All forms of pre- and post-indexing with and without writeback can be used. Operate on a base register Rn specified in an instruction. Only word size operands are allowed. Useful in implementing subroutines, when multiple registers need to be stored onto the stack. LDM R10 [R0,R1,R6,R7] R10 is the base register and contains Transfers the contents of locations 1000, 1004, 1008 and 1012 to registers R0, R1, R6 and R7 respectively.

18 Instructions (contd..) Register move instructions Copy the contents of register R0 to register R1. - MOV R1, R0 Load the an immediate operand in the low-order 8 bits of register R0. - MOV R1, #76

19 Instructions (contd..) Arithmetic instructions Arithmetic instructions operate on operands given in the general-purpose registers or on immediate operands. Memory operands are not allowed for these instructions (Typical of RISC architectures). OPcode Rd, Rn, Rm - Operation is performed using the operands in registers Rn, Rm. - Result is stored in register Rd. OPcode Rd, Rn, #Operand. - Second operand may also be given in an immediate mode. OPcode Rd, Rn, Rm, LSL #2 - When the second operand is specified in a register, it may also be shifted left or right.

20 Instructions (contd..) Operand shift instructions Shifting and rotation operations are performed as separate instructions in most other processors In case of ARM, shifting and rotation operations can be incorporated into most instructions. - Saves code space and may improve execution time performance.

21 Instructions (contd..) Conditional branch instructions Contain a signed 2’s complement offset that is added to the updated contents of the PC to generate branch target address. Condition to be tested to determine whether or not branching should take place is specified in the high-order 4 bits of the instruction word. Condition 31 OP code 2827 Offset LOCATION = 1100 BEQ LOCATION Branch target instruction 1004 updated [PC] = 1008 Offset = 92 Instruction format Note that in general the PC would have pointed to But here it points to 1008 for the reasons of pipelined execution.

22 Instructions (contd..) Instructions to set condition codes Conditional branch instructions check the condition code flags in the status register. Condition code flags may be set by arithmetic and logic operations if explicitly specified to do so by a bit in the OP-code. Some instructions are provided for the sole purpose of setting condition code flags.

23 Assembly language  AREA indicates the beginning of a block of memory  Uses the argument CODE or DATA.  AREA CODE indicates the beginning of a code block.  AREA DATA indicates the beginning of a data block.  ENTRY directive indicates that the program is to begin execution at the following instruction.  DCD directive is used to label and initialize a data operand.  EQU directive is used to equate symbolic names to constants.  RN directive is used to assign a symbolic name to a register indicative of its usage in the program.

24 Subroutines Branch and link ( BL ) instruction is used to call a subroutine. Operates in the same way as other branch instructions. In addition, stores the return address of the next instruction following the BL instruction into register R14. R14 acts as a link register. For nested subroutines, the contents of the link register may be stored on the stack by the subroutine. Register R13 acts as the stack pointer. Parameters can be passed through registers or on the stack.

25 Simple programs in ARM assembly language LDRR1,NLoadcountintoR1. LDRR2,POINTERLoadaddressNUM1intoR2. MOVR0,#0ClearaccumulatorR0. LOOPLDRR3,[R2],#4Loadcurrent number into R3. ADDR0,R0,R3AddnumberintoR0. SUBSR1,R1,#1DecrementloopcounterR1. BGTLOOPBranchbackifnotdone. STRR0,SUMStoresum. Add N numbers: - The first number is stored at the starting address NUM1. - The count of numbers to be added is stored at address N. - Store the result at location SUM. - Size of each number to be added is Word.

26 Simple programs in ARM assembly language MemoryAddressing addressordata labelOperationinformation AssemblerdirectivesAREACODE ENTRY StatementsthatLDRR1,N generateLDRR2,POINTER machineMOVR0,#0 instructionsLOOPLDRR3,[R2],#4 ADDR0,R0,R3 SUBSR1,R1,#1 BGTLOOP STRR0,SUM AssemblerdirectivesAREADATA SUMDCD0 N 5 POINTERDCDNUM1 DCD3,17,27,12,322 END   Beginning of the code block Begin execution from next instruction. Beginning of the data block Label & initialize data operands