EECE631 Microcomputer System Design - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

EECE631 Microcomputer System Design

Description:

Terminology. Big-Endian Bit Ordering left most bit is bit 0, right most bit ... Terminology ... A program that allows the computer to translate assembly language to ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 33
Provided by: lenh
Category:

less

Transcript and Presenter's Notes

Title: EECE631 Microcomputer System Design


1
EECE631 Microcomputer System Design
  • Spring 2008
  • Lecture 2 ARM Assembly
  • Chris Lewis
  • clewis_at_ksu.edu

2
Terminology
  • Big-Endian Bit Ordering left most bit is bit 0,
    right most bit is N-1 on N bit Machine
  • Big-Endian Byte Ordering - byte 0 is stored in
    the lowest address, byte N-1 is stored in the
    highest address on N byte transfer
  • Little-Endian Bit Ordering
  • Little-Endian Byte Ordering

3
Software Terminology
  • Assembly Language A programming language that
    allows the use of mnemonics in place of binary
    machine language instructions
  • Assembler A program that allows the computer to
    translate assembly language to machine language
  • Object file A machine language program that is
    the result of assembly process performed by an
    assembler

4
Reference Material
ARM ASSEMBLY LANGUAGE PROGAMMING By Peter Knaggs
and Stephen Welsh
5
Assembly Language Statement
6
CPU Registers
  • R1-R15 32 bit registers
  • R0-R12 General Purpose Registers
  • R13 Stack pointer
  • R14 GPR and Link Register
  • R15 Program counter and Status Register
  • CPSR Current Program Status Register
  • SPSR Saved Program Status Register

7
CPSR, SPSR
8
Program Counter
  • R15 is split into two parts.
  • Bits 2 to 25 are the program counter (PC).
  • address of the next instruction to be fetched
  • only 24 bits out of 26, 2 lowest bits always 0.
  • PC0 on reset
  • Normally PC with each non-branching instruction
  • Status Register R15 Bits 0,2,26,27,28,29,30,31

9
Assembly Program Module
  • Begins w/Module Control Directive NAME
  • Ends w/Module Control Directive END
  • NAME main
  • .
  • .
  • .
  • END main

10
ARM supports two Code types
  • ARM, CODE32
  • 32 bit instuction set
  • CODE16
  • 16, or possibly 32 bit Thumb instruction set
  • Assembly directive within a module determines
    what kind of code is generated
  • ARM Use 32 bit ARM machine code
  • CODE32 Use 32 bit ARM machine code
  • DATA Define a data segment within the code
  • THUMB Use Thumb or Thumb2 machine code
  • CODE16 Use Thumb or Thumb2 machine code

11
Example
12
Within code, there may be data
DATA assembly directive to insert data within
code
Question What happens if the PC gets set to an
address containing data? Question Can a program
modify itself?
13
Segments Program Location Counter
  • DATA or CODE
  • Relocatable or NOT
  • RSEG Relocatable segment
  • ASEGN Named relocatable segment
  • ASEG Absolute segment
  • ORG Sets PLC
  • Aligned
  • ALIGNRAM increments PLC to align
  • ALIGNROM fills with zeros to align
  • EVEN PLC to even address
  • ODD PLC to odd address

14
Value Assignments
  • permanent value to local module
  • ALIAS permanent value to local module
  • ASSIGN temporary value
  • DEFINE file wide value
  • EQU permanent value to local module
  • LIMIT checks value against limits
  • SET temporary value
  • SETA temporary value
  • VAR temporary value

15
Example
16
Conditional Directives
  • IF,ELSE,ELSEIF,ENDIF

17
MACRO Processing
  • MACRO defines a macro
  • ENDM ends the macro
  • REPT repeats instructions n times
  • REPTC repeats but subs chars
  • REPTI repeats but subs strings
  • ENDR ends repeat section

18
Example
19
Predefined Macro Symbols
  • _agrs of arguments passed to macro

20
Macro Example
  • ORG 0
  • B main
  • base EQU 0x100
  • count EQU 0x110
  • init EQU 0x120
  • CODE32
  • PUBLIC main
  • main MOV R0, 0
  • REPTI a, base, count, init variable a
    gets three values, base, count, init
  • LDR R1, a load R1
    with a
  • STRB R0, R1, 0 store
    first byte of R0 at address of R1 offset by 0
  • ENDR
  • B . Branch to here, infinite loop

21
Main Limitation of RISC
  • Loading a 32 bit number into a 32 bit register
    with an assembly command with only 32 bits.
  • Use Data Segments and offset from the PC
  • The power pc can also use multiple commands
  • Load upper half word
  • Shift left to get into upper half
  • Load lower half word
  • Add or OR the two together
  • LDR R0,(some defined data label)
  • Assembler figures it out for you

22
ARM ASSEMBLY
23
ARM ASSEMBLY
24
Assembly
25
Assembly
26
Assembly
27
Assembly
28
Addressing Modes
29
Addressing Modes
30
Addressing Modes
31
Operand 2
32
Condition Codes
Write a Comment
User Comments (0)
About PowerShow.com