CS 2731 Computer Organization II Recitation LAB 1 - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

CS 2731 Computer Organization II Recitation LAB 1

Description:

Office: SB.3.01.04 (cubicle #2) Office hour: Mon. & Wed. 2:30~4:00 pm. Office phone: 458-5737 ... You can attend either sections or both! ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 23
Provided by: csU66
Category:

less

Transcript and Presenter's Notes

Title: CS 2731 Computer Organization II Recitation LAB 1


1
CS 2731 Computer Organization II Recitation LAB 1
  • Introduction and Tools

Thanks Kyung Min Su
2
TA Contact Information
  • Name Lijie Zhang
  • Email lijez_at_cs.utsa.edu
  • Office SB.3.01.04 (cubicle 2)
  • Office hour Mon. Wed. 230400 pm
  • Office phone 458-5737
  • References
  • Text book MIPS Assembly Language Programming,
    Robert L. Britton, Pearson Education, Inc. 2004
  • http//www.cs.unibo.it/solmi/teaching/arch_2002-2
    003/AssemblyLanguageProgDoc.pdf

3
Notice
  • You can attend either sections or both!
  • The grade of this course, CS 2731, will be 10 of
    CS 2733 course. (Please refer the syllable of CS
    2733 for more information.)

4
Assembly Language
  • Assembly Language
  • Human-readable symbolic language for the machine
    instruction.
  • Example
  • assembly language statement add t0,t1,t2
  • machine instruction 0000 0001 0010 1011 1000
    0000 0010 0000
  • Linker
  • Combines object and library files into executable
    files

5
Assembly language
  • Used when
  • Speed/size important (embedded systems)
  • Recoding critical part
  • Exploit specialized instructions
  • No high-level language is available
  • Drawbacks
  • Machine-specific
  • Longer code
  • Hard to read

6
Sample C Program
  • void main()
  • // This program prints the sum of A and B
  • int A 2
  • int B 3
  • printf("d", AB)

7
Sample assembly program
  • .data Data segment
  • A .word 2 A is an integer with a value of 2
  • B .word 3 B is an integer with a value of 3
  • .text Text Segment
  • .globl main
  • main this program prints the sum of A and B
  • lw t0, A load the value of A into register
    t0
  • lw v0, B load the value of B into register
    v0
  • add a0, t0, v0 add t0 and v0 and load the
    result into a0
  • li v0, 1 system call print the value of a0
  • syscall
  • li v0, 10 system call exit the program
  • syscall

8
MIPS
  • MIPS
  • Target machine
  • RISC Architecture
  • Load-Store Instruction Set (ISA)
  • MIPS Assembly Language
  • Fixed-length instruction 32 bits
  • Arithmetic Instruction
  • Performs only ONE operation
  • Have three variables
  • Instruction operands are registers (32 bit)

9
MIPS simulator
  • SPIM
  • Software Simulator for MIPS 32 architecture
  • Reads and executes assembly language file
  • Provides debugger and OS services
  • Versions
  • Spim
  • Simplest
  • Command-line-driven program
  • Xspim
  • X-windows environment for Unix and Linux
  • PCspim
  • Microsoft windows
  • Installation
  • http//www.cs.wisc.edu/larus/spim.html

10
Using PCSpim
  • Double-click PCSpim icon on the desktop.
  • Click Start gt All Programs gt PCSpim

11
(No Transcript)
12
Window Panes
  • Control buttons
  • Register Display
  • shows the contents (bit patterns in hex) of
  • All 32 general purpose registers
  • floating point registers, and a few others
  • Text segment
  • Shows assembly language program source
  • Machine instructions (bit patterns in hex)
  • Addresses of their memory locations.
  • Data segment
  • MIPS memory that hold ordinary data
  • data pushed onto a stack.
  • Messages
  • Messages from the simulator (often error messages)

13
Control buttons
  • Open
  • Save log file
  • Go (run)
  • Break
  • Breakpoints

14
Exercise
  • Run Text editor.
  • Type the first sample code on the course web
    page.
  • (http//www.cs.utsa.edu/yum/7sp_2733/course.html
    )
  • Save the file as add_A_B.asm.
  • Run spim and execute the add_A_B.asm

15
Exercise
  • PCSpim
  • double click PCSpim to run it.
  • help (or ?)
  • load add_A_B.asm
  • run
  • check the result 5
  • quit (or exit)
  • spim
  • print_symbols
  • print_all_regs

16
Exercise
  • add_A_B.asm
  • The program prints the sum of A and B.
  • A 2, B 3, Result 5
  • sum_integers.asm
  • Read the input N and prints the sum of the
    integers from 1 to N.

17
Using spim (or xspim)
  • Start spim
  • Type spim (or xspim) at prompt
  • Write assembly source program
  • Use text editor not a word processor to create
    program file
  • Load a program file into memory
  • load file name
  • Run the program at optional address
  • run ltaddressgt
  • Debug
  • step ltNgt step the program for N insruction
  • continue continue program execution without
    stepping
  • print N print register N
  • print address print contents of memory at
    address
  • Exit the simulator
  • exit or quit

18
spim example
19
MIPS Architecture
  • Load-Store Instruction Set
  • Operands are 32 registers
  • Register size 32 bits
  • Fixed-length instruction 32 bits

20
Register
No special purpose
21
MIPS System calls
22
Using System calls
  • Read integer
  • li v0, 5
  • syscall
  • v0 has the input value.
  • Write integer
  • a0 has the value to be printed.
  • li v0, 1
  • syscall
Write a Comment
User Comments (0)
About PowerShow.com