Computer Architecture - PowerPoint PPT Presentation

About This Presentation
Title:

Computer Architecture

Description:

Computer Architecture MIPS Simulator and Assembly language. * – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 13
Provided by: GeorgeKout78
Learn more at: http://www.cs.iit.edu
Category:

less

Transcript and Presenter's Notes

Title: Computer Architecture


1
Computer Architecture
  • MIPS Simulator and Assembly language.

2
MIPS AND SPIM
  • SPIM IS A SIMULATOR THAT RUNS PROGRAMS FOR THE
    MIPS R2000/R3000 RISC (REDUCED INSTRUCTIONS SET
    COMPUTER).
  • SPIM IS BASED ON A VIRTUAL MACHINE ( A SIMULATION
    OF THE ACTUAL MICROPROCESSOR).
  • SINCE SPIM IS A SIMULATOR CERTAIN THINGS ARE NOT
    IDENTICAL TO THE ACTUAL COMPUTER
  • TIMING.
  • MEMORY CACHES OR MEMORY LATENCY.
  • DELAYS FOR FLOATING POINT OPERATIONS OR
    MULTIPLICATIONS OR DIVISIONS.

3
MIPS AND SPIM
  • INFORMATION ON THE ASSEMBLY LANGUAGE CAN BE FOUND
    IN
  • APPENDIX A OF THE TEXT FOR COMPUTER ARCHITECTURE
  • BY GOING TO THE WEB SITE www.cs.wisc.edu/larus/s
    pim.html AND DOWNLOADING THE PDF FILE OF APPENDIX
    A OF THE TEXT
  • THE BACK COVER OF THE TEXT HAS A SYNOPSIS OF THE
    ASSEMBLY LANGUAGE INSTRUCTIONS.

4
MIPS AND SPIM
  • Assembler syntax
  • Comments start with a . Everything from the the
    sharp sign to the end of the line is ignored.
  • Identifiers are a sequence of alphanumeric
    characters, underbars ( _ ) and ( . ) that do
    not begin with a number.
  • Opcodes for instructions are reserved words that
    are not valid identifiers.
  • Labels are declared at the beginning of a line
    followed by a colon
  • Item .word 1
  • Strings are enclosed in double quotes.
  • Special characters follow C , newline \n, tab
    \t, quote \ .
  • .align n --- Align the next data on a 2
    raised to the n power bytes boundary.
  • .align 2 means aligns the next value on a
    word boundary (4 bytes)

5
MIPS AND SPIM
  • .ascii str ---- Store the string in memory, but
    do not null-terminate it.
  • .asciiz str ---- Store the string in memory and
    null terminate it.
  • .byte b1, ., bn ---- Store the n values in
    successive bytes in memory.
  • .data ltaddrgt --- The following data items
    should be stored in the data segment. If the
    argument addr is present the arguments are stored
    beginning with address ltaddrgt.
  • .double d1, .., dn ---- Store the n floating
    point double precision numbers in successive
    memory locations.
  • .extern sym size ----- Declare that the data
    stored in sym is size bytes large and it is a
    global symbol. This directive allows the
    assembler to store the datum in a portion of the
    data segment that is efficiently accessed via
    register gp .
  • .float f1, ,fn ---- Store the n floating
    point single precision numbers in successive
    memory locatoions.

6
MIPS AND SPIM
  • .globl sym Declare that symbol sym is global
    and can be refernced from other files.
  • .half h1, , hn ----Store the n 16-bit
    quantities in successive memory halfwords.
  • .kdata ltaddrgt ---- The following data items
    should be stored in the kernel data segment. If
    argument addr is present, the items are stored
    beginning with address ltaddrgt.
  • .ktext ltaddrgt ----- The next items are put in
    the kernel text segment. In SPIM these items may
    only be instructions or words. If the argument
    addr is there, the items are stored beginning
    with address ltaddrgt.
  • .space n ---- Allocate n bytes of space in the
    current segment (which must be the data segment
    in SPIM).
  • .text ltaddrgt ----- The next items are put in the
    user text segment. In SPIM these items may only
    be instructions or words. If the argument addr
    is there, the items are stored beginning with
    address ltaddrgt.

7
MIPS AND SPIM
  • .word w1, , wn ----- Store the n-32 bit
    quantities in successive memory words.
  • SYSTEM CALLS
  • SPIM provides a small set of operating-system
    like services through the system call
    instruction. To request a service a program loads
    the system call code into register v0 and the
    arguments into registers a0 a3 (or f12 for
    floating point values)
  • print_int , the code is 1 , the argument
    goes in a0 integer
  • print_float, the code is 2 , the argument goes
    to f12 float
  • print_double, the code is 3, the argument goes
    into f12double
  • print_string, the code is 4, the argument goes
    into a0string
  • read_int, the code is 5, the result goes in v0

8
MIPS AND SPIM
  • read_float, the code is 6, the result goes in
    f0
  • read_double, the code is 7, the result goes in
    f0
  • read_string, the code is 8, the argument is
    a0buffer, a1length
  • sbrk , the code is 9, the argument is
    a0amount, the result is address in v0
  • exit, the code is 10
  • For example to print the answer 5, use
  • .data
  • str .asciiz the answer .text li
    v0, 4 la a0, str
  • syscall li v0, 1 li a0,
    5 syscall

9
MIPS REGISTERS
  • NAME NUMBER USAGE
  • zero 0 Constant 0
  • at 1 Reserved for assembler
  • v0 2 Expression evaluation and result of
    a function
  • a0 4 Argument 1
  • a1 5 Argument 2
  • a2 6 Argument 3
  • a3 7 Argument 4
  • to-t7 8-15 Temporary (not preserved
    across call).

10
MIPS REGISTERS
  • s0- s7 16-23 Saved Temporary (preserved
    across call)
  • t8 and t9 24, 25 Temporary (not preserved
    across call)
  • k0, k1 26, 27 Reserved for OS kernel
  • gp 28 Pointer to global area
  • sp 29 Stack Pointer
  • fp 30 Frame pointer
  • ra 31 Return address (used by function
    call)

11
MIPS REGISTERS
  • MIPS CONTAINS 32 GENERAL PURPOSE REGISTERS.
  • REGISTER 0 ALWAYS CONATINS THE HARDWIRED 0
    VALUE.
  • REGISTERS at, k0, k1 ARE RESERVED FOR USE BY
    THE ASSEMBLER AND THE OS.
  • REGISTERS a0-a3 ARE USED TO PASS THE FIRST 4
    ARGUMENTS TO ROUTINES (REMAINING ARGUMENTS ARE
    PASSED ON THE STACK).
  • REGISTERS v0 - v1 ARE USED TO RETURN VALUES
    FROM FUNCTIONS.
  • REGISTERS to - t9 ARE CALLER SAVED REGISTERS
    FOR TEMPORARY QUANTITIES 9NOT PRESERVED ACROSS
    CALLS)

12
MIPS REGISTERS
  • REGISTERS s0 - s7 ARE CALLEE SAVED REGISTERS
    THAT HOLD LONG LIVED VALUES THAT SHOULD BE
    PRESERVED ACROSS CALLS.
  • REGISTER sp POINTS TO THE FIRST FREE LOCATION ON
    THE STACK.
  • REGISTER fp IS THE FRAME POINTER.
  • REGISTER ra HAS THE RETURN ADDRESS FOR A CALL
  • REGISTER gp POINTS TO THE MIDDLE OF TH E64 K
    BLOCK MEMORY OF THE HEAP THAT HOLDS GLOBAL
    VARIABLES AND CONSTANTS.
Write a Comment
User Comments (0)
About PowerShow.com