CPE 431531 Chapter 2 Instructions: Language of the Computer - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

CPE 431531 Chapter 2 Instructions: Language of the Computer

Description:

1. Electrical and Computer Engineering. CPE 431/531 ... has led to an architecture that is difficult to explain and impossible to love. ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 27
Provided by: glen3
Category:

less

Transcript and Presenter's Notes

Title: CPE 431531 Chapter 2 Instructions: Language of the Computer


1
CPE 431/531Chapter 2 Instructions Language
of the Computer
  • Dr. Rhonda Kay Gaede
  • UAH

2
2.1 Introduction
  • The words of a computers language are called
    instructions and its vocabulary is called an
    instruction set.
  • Instruction sets are more similar than they are
    different
  • Goal is to find a language that makes it easy to
    build the hardware
  • Stored-program concept
  • Instructions and data can be stored in memory in
    as numbers

3
2.2 Operations of the Computer Hardware Basics
of MIPS Arithmetic
  • We need arithmetic
  • add a, b, c
  • From high level
  • a b c d e
  • Fixing the number of operands keeps the hardware
    simple.
  • Design Principle 1
  • Simplicity favors regularity

4
2.2 Operations of the Computer Hardware The
Role of the Compiler
  • Compilation is the process of creating MIPS
    assembly language instructions from a high level
    language instruction (C).
  • Examples
  • a b c
  • d a e
  • f (g h) (i j)

5
2.3 Operands of the Computer Hardware MIPS
Basics
  • In high level languages, variables live in
    _____________.
  • In MIPS assembly, operands live only in
    _______________.
  • ______________________ instructions move
    variables from memory/registers to
    registers/memory.
  • MIPS has 32 registers and an address space of 232
    memory bytes.
  • Design Principle 2 Smaller is faster.
  • _____________________________________

6
2.3 Operands of the Computer Hardware Memory
Operands First Pass
  • Data transfer instructions
  • _____________________________________________
  • _____________________________________________
  • Compiling an Assignment When an Operand is in
    Memory
  • A is an array of 100 words, base pointer s3
  • g s1, h s2
  • g h A8
  • Hardware/Software Interface
  • A compiler _______________, ______________________
    ______, _____________________________________.

7
2.3 Operands of the Computer Hardware - Memory
Operands Second Pass
  • Bytes/Words
  • 32-bit words consist of 4 8-bit bytes
  • MIPS is _________ addressable
  • g h A8
    A12 h A8
  • Constants or Immediate Operands
  • addi s3, s3,4
  • Design Principle 3
  • ________________________________________

8
2.4 Representing Instructions in the Computer
R-type Instructions
  • Translating a MIPS assembly instruction into a
    machine instruction _________________________
  • MIPS Fields
  • op rd
  • rs shamt
  • rt funct

9
2.4 Representing Instructions in the Computer
I-Type Instructions
  • Design Principle 4
  • ___________________________________
  • For data transfer, address offset is limited to
    _________ bytes, _________ words.
  • Another Translation Example A300 h A300

10
2.6 Instructions for Making Decisions
Instruction Examples and Compilation
  • Two conditional ones for now
  • beq register1, register2, L1
  • bne register1, register2, L1
  • if (i j)
  • f g h
  • else
  • f g h

11
2.6 Instructions for Making Decisions Add
Another Decision
  • Less than is useful, i.e., for (i 0 i lt 10
    i)
  • slti t0, s1, 10
  • bne t0, zero, offset
  • slt t0, s0, s1
  • bne t0, zero, offset

12
2.7 Supporting Procedures in Computer Hardware
Getting Started
  • Steps involved in calling a procedure (function)
  • Make parameters available to the called
    procedure.
  • Transfer control to the procedure
  • Acquire the needed space for the procedure.
  • Perform the desired task.
  • Make result available to the calling procedure
  • Transfer control back to calling procedure.
  • Support comes in registers and instructions
  • Registers
  • a0-a3 - _______________________________________
  • v0-v1 - _______________________________________
  • ra ______________________________________
  • Instructions
  • jal
  • jr

13
2.7 Supporting Procedures in Computer Hardware
Compiling a Leaf Procedure
  • int leaf_example (int g, int h, int i, int j)
  • int f
  • f (g h) - (i j)
  • return(f)
  • leaf_example sub sp, sp, 12
  • sw t1, 8(sp)
  • sw t0, 4(sp)
  • sw s0, 0(sp)
  • add t0, a0, a1
  • add t1, a2, a3
  • sub s0, t0, t1
  • add v0, s0, Zero
  • lw s0, 0(sp)
  • lw t0, 4(sp)
  • lw t1, 8(sp)
  • add sp, sp, 12

14
2.7 Supporting Procedures in Computer Hardware
Leaf Example Stack
15
2.7 Supporting Procedures in Computer Hardware
Nested Procedures
  • Calling Procedure
  • Pushes its argument registers onto the stack
    ___________ ____________________
  • Pushes any temporary registers it needs
    _____________________ ____________________________
    _
  • Pushes ra onto the stack
  • Called Procedure
  • Pushes saved registers onto the stack

16
2.7 Supporting Procedures in Computer Hardware
Nested Procedure Compilation
int fact (int n) if (n lt 1) return (1) else
return (fact(n-1)) fact addi sp, sp,
-8 sw ra, 4(sp) sw a0, 0(sp) slti t0,
a0, 1 beq t0, zero, L1 addi v0, zero,
1 addi sp, sp, 8 jr ra L1 addi a0, a0,
-1 jal fact lw a0, 0(sp) lw ra,
4(sp) addi sp, sp, 8 mul v0, a0,
v0 jr ra
17
2.7 Supporting Procedures in Computer Hardware
More About the Stack
  • Allocating Space for Automatic Variables
  • In addition to storing saved registers, the stack
    holds ___________________________________
  • Saved registers ______________________________
    ________________________________

18
2.7 Supporting Procedures in Computer Hardware
The Heap
  • Space is needed for static variables and dynamic
    data structures
  • Space is reserved and freed on the heap using
    explicit system calls.
  • Register Usage
  • zero 0
  • v0-v1 2-3
  • a0-a3 4-7
  • t0-t7 8-15
  • s0-s7 16-23
  • t8-t9 24-25
  • gp 28
  • sp 29
  • fp 30
  • ra 31

19
2.9 MIPS Addressing for 32-Bit Immediates and
Addresses 32-Bit Immediates
  • 32-Bit Immediate Operands
  • Upper 16 Bits - _____________________________
  • Lower 16 Bits - _____________________________
  • Loading 003D 0900

20
2.9 MIPS Addressing for 32-Bit Immediates and
Addresses Addresses
  • Addresses in Branches and Jumps
  • j 10000
  • bne s0, s1, Exit
  • Elaboration For jumps, we give only 28 bits,
    from whence springeth the other 4?
  • Branching Far Away

21
2.9 MIPS Addressing Addressing Mode Summary
  • MIPS Addressing Mode Summary
  • Register
  • Base
  • Immediate
  • PC-Relative
  • Pseudodirect

22
2.10 Translating and Starting a Program
23
2.11 How Compilers Optimize
  • High-level Optimizations
  • _______________________
  • _______________________
  • Local and Global Optimizations
  • ________________________
  • _________________________
  • _________________________

24
2.16 Real Stuff IA-32 Instructions The Early
Years
  • 1978 - 8086 ____________________________________
  • 1980 8087 ____________________________________
    _______________________________________
  • 1982 80286 ____________________________________
  • 1985 80386 ____________________________________
    _________________________________
  • 1989-1995
  • 1989 80486, 1992 Pentium, 1995 Pentium Pro
  • _______________________________________________
  • 1997 MMX _________________________________
    ____________________________________________

25
2.16 Real Stuff IA-32 Instructions The Later
Years
  • 1999 Pentium III _______________________________
    _______________________________________________
    ________________________________________
  • 2001 Pentium 4 ________________________________
    _______________________________________
  • 2003 AMD ____________________________________
    __________________________
  • 2004 EM64T __________________________________
    _______________________________________________
  • This checkered ancestry has led to an
    architecture that is difficult to explain and
    impossible to love. What it lacks in ___________,
    it makes up in ____________.

26
2.17 Fallacies and Pitfalls
  • Fallacy More powerful instructions mean higher
    performance.
  • Fallacy Write in assembly language to obtain the
    highest performance.
  • Pitfall Forgetting that sequential word
    addresses in machines with byte addressing do not
    differ by one.
Write a Comment
User Comments (0)
About PowerShow.com