Lecture 9: Machine Language and Addressing - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Lecture 9: Machine Language and Addressing

Description:

As: The addressing bits responsible for the addressing mode used for the source (src) ... source or destination (so that an additional one need not be specified) ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 24
Provided by: rober244
Category:

less

Transcript and Presenter's Notes

Title: Lecture 9: Machine Language and Addressing


1
Lecture 9 Machine Language and Addressing
  • Lecturer
  • Mr Robert Ross

2
Overview
  • Machine Language
  • Addressing Modes
  • Physical Address Calculation

3
Machine Language
  • Processors only understand machine language (also
    called object code or machine code)
  • Machine language is a collection of bits used to
    specify different instructions
  • Machine language is architecture specific

4
Language Flow
  • High level languages are complied to assembly
    language
  • Assembly language is assembled into machine code
  • Assembly language is a human readable
    representation of machine code

High Level Language (eg. C, Java)
Assembly Language
Machine Code
Compiled
Assembled
5
Reading Machine Code
  • Machine code can be decoded back into assembly
    language
  • Machine code instructions are made up of several
    parts including
  • Op-code bits to encode the instruction
  • src The source operand defined by As and S-reg
  • dst The destination operand defined by Ad and
    D-reg
  • As The addressing bits responsible for the
    addressing mode used for the source (src)
  • S-reg The working register used for the source
    (src)
  • Ad The addressing bits responsible for the
    addressing mode used for the destination (dst)
  • D-reg The working register used for the
    destination (dst)
  • B/W Byte or word operation 0word, 1byte

6
Reading Machine Code
  • For the MSP430 there are 3 types of machine code
    formats
  • Double Operand
  • Single Operand
  • Jump

7
Double-Operand
  • Two different memory locations are accessed
  • Example instructions
  • MOV
  • ADD
  • SUB

8
Single-Operand
  • Have an implicit source or destination (so that
    an additional one need not be specified)
  • Example instructions
  • RRA (Rotate Right)
  • PUSH
  • RETI

9
Jump
  • Jump commands have a separate format
  • 10-bit offset allows a jump range /- 512 of the
    PC
  • Examples
  • JNE
  • JMP
  • JGE

10
Examples
  • Moving Register to Register
  • Assembly mov R5, R6 (1 Cycle)
  • Machine 0x4506 (0100010100000110)
  • Moving Register to Memory
  • mov R5, 0x0200 (4 Cycles)
  • 0x4580 0x0200 (0100010110000000 0000001000000000)
  • Adding 5 to the value in the Register
  • add 5, R5 (2 cycles)
  • 0x5035 0x0005 (0101000000110101 0000000000000101)
  • http//mspgcc.sourceforge.net/assemble.html

OP-CODE
(R5)
(R6)
11
Addressing Modes
  • The MSP430 has 7 Addressing modes

12
Addressing Modes - Analogy
  • If someone asks you how to get to this room what
    answers could you give?
  • GPS Coordinates (Absolute address)
  • Goto Building X, turn right and walk 10 meters
    (Indirect address)
  • From where you are now turn left and walk 50
    meters (relative address symbolic in TI
    assembly)
  • Pick them up and take them here directly
    (Immediate address)
  • Multiple ways to get someone to this room
  • Multiple ways for the CPU to address areas within
    memory

13
Register Addressing
  • Operations directly between the contents in
    registers
  • Examples
  • MOV R5, R6
  • ADD R7, R9

14
Indexed Addressing
  • The value in the register is added to the offset
    to calculate the address

15
Symbolic Addressing
  • Indirect form of addressing
  • Format MOV 500, R5
  • Rather than storing 500, X is stored, where 500
    PC X
  • Address referenced as PC (at point X) X

16
Absolute Addressing
  • The actual physical address is stored
  • Normally used for hardware peripherals

17
Indirect Addressing
  • Store addresses in registers
  • Refers to the contents of the address which is
    stored in the register

18
Indirect Autoincrement Addressing
  • Same as indirect, except that the address in the
    source register is incremented (1 for byte
    operation, 2 for word operation)

19
Immediate Addressing
  • Source is a constant value
  • Examples
  • MOV 4Fh, R5 Moves the value 4F into R5
  • ADD 21, R6 Adds the value 21 to R6

20
Addressing Modes - Syntax
  • Syntax for addressing modes
  • Register R1
  • Indexed 2(R5)
  • Symbolic 500
  • Absolute 0x5000
  • Indirect _at_R5
  • Indirect Autoincrement _at_R5
  • Immediate 45 (use to signify immediate)
  • 45 45 Decimal
  • 45h 45 Hex
  • 01001001b 01001001 Binary

21
Physical Address Calculations
  • The physical address is the real address where
    something is stored
  • Because different addressing modes and offsets
    are used, the physical address needs to be
    calculated with care

22
Physical Address Calculations
  • What are the source and destination addresses?
  • MOV 10(R5), 2(R6)
  • Source 110
  • Destination 202
  • MOV 500, 5000
  • Source 500
  • Dest 5000
  • MOV _at_R7, 504
  • Source 500
  • Dest 504

23
Summary
  • Computers understand machine language
  • Assembly language is a human readable version of
    machine language
  • Microprocessors have several different addressing
    modes, providing several methods to address memory
Write a Comment
User Comments (0)
About PowerShow.com