CS 3841 Computer Organization Recitation LAB 1 - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

CS 3841 Computer Organization Recitation LAB 1

Description:

Sign up sheet at each recitation ... Breakpoints. 19. Exercise. Run Text editor. Type the first sample code on the course web page. ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 22
Provided by: csU66
Category:

less

Transcript and Presenter's Notes

Title: CS 3841 Computer Organization Recitation LAB 1


1
CS 3841 Computer Organization Recitation LAB 1
  • Introduction and Tools

Li Xu (Lee)
2
TA Contact Information
  • Name Li Xu(Lee)
  • Email lxu_at_cs.utsa.edu
  • Office 3.02.07 cubicle 9
  • Office hour TR 1000-1130 a.m
  • Office phone (210) 782-6592

3
Notice
  • Sign up sheet at each recitation
  • The grade of this course, CS 3841, will be the
    same as that of CS 3843 course. (Please refer the
    syllable of CS 3843 for more information.)

4
Assembly Language
  • Assembly Language
  • Human-readable mnemonic 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)
  • Register size 32 bits

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 xspim
  • Start xspim
  • Type 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
  • Show Console
  • terminal -gt popup console
  • Exit the simulator
  • exit or quit

11
spim example
12
Registers
13
MIPS System calls
14
Using System calls
  • Read integer
  • li v0,5
  • syscall v0 has the input value
  • Write integer
  • li v0,1
  • syscall a0 has the value to be printed

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

16
(No Transcript)
17
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)

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

19
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

20
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

21
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.
Write a Comment
User Comments (0)
About PowerShow.com