CSE 305 Introduc0on to Programming Languages Lecture 4. SUNY- Buffalo Zhi Yang Courtesy of Google

Size: px
Start display at page:

Download "CSE 305 Introduc0on to Programming Languages Lecture 4. SUNY- Buffalo Zhi Yang Courtesy of Google"

Transcription

1 CSE 305 Introduc0on to Programming Languages Lecture 4 SUNY- Buffalo Zhi Yang Courtesy of Google

2 No0ce Board Homework2 is posted, it is due on June 17, 2013(Monday). You can schedule your 0me working on it accordingly. Homework1 is extended to June 3, 2013 (Monday) 11:59pm. It should be no more extension.

3 Quiz Quiz 1 will be given on June 6, 2013 (Thursday). It will take half an hour and cover material from lecture 1 to lecture 5.

4 MIPS product SGI Octane 2 UNIX worksta0on MIPS R10000 Nintendo 64 MIPS R4300

5 MIPS dies Different dies share similar architecture

6 System Bus Von Neumann computer model.

7 Address Transla0on Address & Data Buses

8 Register Alloca0on

9 MUX 4 add $s3,$t1,$t2 Branch MemRead SIGN EXT M U X PC INST REG MUX ALUSrc M E M Write Reg1 Read Reg2 GENERIC REG FILES MUX RegDst Read Reg1 RegWrite ALUOp Mem2Reg CONTROL Mem write

10 MUX 4 Lw $t2,offset($t1) Branch MemRead SIGN EXT M U X PC INST REG MUX ALUSrc M E M Write Reg1 Read Reg2 GENERIC REG FILES MUX RegDst Read Reg1 RegWrite ALUOp Mem2Reg CONTROL Mem write

11 MUX 4 beq $t2,$t1,offset Branch MemRead SIGN EXT M U X PC INST REG MUX ALUSrc M E M Write Reg1 Read Reg2 GENERIC REG FILES MUX RegDst Read Reg1 RegWrite ALUOp Mem2Reg CONTROL Mem write

12 MIPS address space 0x7fffffff 0x7fffeffc reserved stack segment 0x x x data segment text segment (instructions) reserved

13 Pseudoinstruc0ons Pseudoinstruc?ons do not correspond to real MIPS instruc0ons. Instead, the assembler, would translate pseudoinstruc?ons to real instruc0ons (one on more instruc0ons). Pseudoinstruc?ons not only make it easier to program, it can also add clarity to the program, by making the inten0on of the programmer more clear.

14 Func0on Calls In MIPS machines, part of main memory is reserved for a stack. The stack grows downward in terms of memory addresses. The address of the top element of the stack is stored (by conven0on) in the stack pointer register, $sp. MIPS does not provide push and pop instruc0ons. Instead, they must be done explicitly by the programmer. So lets see how 0x7FFFFFFF stack 0x

15 A Factorial Example int fact( int n ) { if (( n == 1) (n==0 )) return (1) else return (fact(n- 1)*n); } int main(){ fact(7); return (0); }

16 MIPS Assembly Direc0ves Common Data Defini0ons:.word w1,..., wn store n 32- bit quan00es in successive memory words.half h1,..., hn store n 16- bit quan00es in successive memory halfwords.byte b1,..., bn store n 8- bit quan00es in successive memory bytes.ascii str store the string in memory but do not null- terminate it strings are represented in double- quotes str special characters, eg. \n, \t, follow C conven0on.asciiz str store the string in memory and null- terminate it

17 MIPS Assembly Direc0ves(Cont.) Common Data Defini0ons:.float f1,..., fn store n floa0ng point single precision numbers in successive memory loca0ons.double d1,..., dn store n floa0ng point double precision numbers in successive memory loca0ons.space n reserves n successive bytes of space.align n align the next datum on a 2n byte boundary. For example,.align 2 aligns next value on a word boundary..align 0 turns off automa0c alignment of.half,.word, etc. 0ll next.data direc0ve

18 MIPS Calling Conven0on 0 zero constant 0 1 at reserved for assembler 2 v0 results from callee 3 v1 returned to caller 4 a0 arguments to callee 5 a1 from caller: caller saves 6 a2 7 a3 8 t0 temporary t7 16 s0 callee saves s7 24 t8 temporary (cont d) 25 t9 26 k0 reserved for OS kernel 27 k1 28 gp pointer to global area 29 sp stack pointer 30 fp frame pointer 31 ra return Address caller saves

19 Step 1, assign registers Let: register 1 = constant 1 register 4 = n register 2 = result Given: register 29 = stack pointer ($sp) register 30 = frame pointer ($fp) register 31 = return address ($ra) for procedure/func0on calls

20 Step 2, Store Data.data prompt:.asciiz "Enter a non- nega0ve integer: " endl:.asciiz "\n"

21 Step 3, Write Code.text.globl factorial # Precondi0ons: # 1st parameter (a0) non- nega0ve integer, n # Postcondi0ons: # result (v0) n factorial factorial: addi $sp, $sp, - 8 # Make space on stack. sw $ra, 0($sp) # Save return address. li $v0, 1 # 0! = 1 beqz $a0, zero # Special case for 0! sw $a0, 4($sp) # Save our argument. addi $a0, $a0, - 1 # Calculate (n- 1)! jal factorial # Result in v0. lw $a0, 4($sp) # Restore our argument. mul $v0, $a0, $v0 # n! = n * (n- 1)! zero: lw $ra, 0($sp) # Restore return address. addi $sp, $sp, 8 # Restore stack pointer. jr $ra # Return..globl main main: addi $sp, $sp, - 4 # Make space on stack. sw $ra, 0($sp) # Save return address. la $a0, prompt li $v0, 4 syscall li $v0, 5 syscall # Display prompt. # Get integer response. move $a0, $v0 # Call factorial func0on. jal factorial move $a0, $v0 li $v0, 1 syscall la $a0, endl li $v0, 4 syscall # Print integer result. # Print endl. li $v0, 0 # Return zero. lw $ra, 0($sp) # Restore return address. addi $sp, $sp, 4 # Restore stack pointer. jr $ra

22 User Stack User Stack No?ce: number in square bracket is address Those with blue color are their ascii representa?on [7ffffe20]..[ ] [7ffffe20] ffffe5d fffffdd ]???? [7ffffe30] 7fffffa3 7fffff93 7fffff7f 7fffff72 ᆪ?????? r?? [7ffffe40] 7fffff62 7fffff3f 7fffff14 7ffffedf b?????????

23 Stack Trace First, every program should have an entry point, for example, QtSpim requires a main label to be declared as global. $sp 0x7ffffe20 word 1 main: addi $sp, $sp, - 4 # Make space on stack. sw $ra, 0($sp) # Save return address. No0ce: in the beginning, value of sp is 0x7ffffe20 value of ra is 0 word 1 $ra = 0x $sp 0x7ffffe1c 0x400018

24 System Call for Input User data segment [ ]..[ ] [ ]..[ ] are all integer [ ] 65746e d6e6f6e e E n t e r a n o n - n e g a [ ] e a00203a t i v e i n t e g e r :.data prompt:.asciiz "Enter a non- nega0ve integer: endl:.asciiz "\n" la $a0, prompt li $v0, 4 syscall # Display prompt. li $v0, 5 syscall # Get integer response.

25 ! Endianness(Courtesy of Wikipedia) In computing, endian and endianness in the most common cases refer to how bytes are ordered within a data item, and endianness is then the same as byte order. [1] A big-endian machine stores the most significant byte first at the lowest byte address while a little-endian machine stores the least significant byte first.! Endian First byte (lowest address) Middle bytes Last byte (highest address) Decimal (hexadecimal 05F5E100) Address Value n 05 big most significant... least significant n+1 F5 n+2 E1 n+3 00 Address Value n 00 little least significant... most significant n+1 E1 n+2 F5 n+3 05

26 Big Endian Machines Tekronix 4051 Graphics Compu0ng System using motorola microprocessor (1975) Mac PowerG5 using PowerPC core (2005) Sega Genesis (1988) An IBM System/360 in use at Volkswagen (1964) DEC PDP- 10 (1968) IBM 2094 System z9 (2005)

27 Li le Endian Machines Apple II using motorola 6502 (1977) Mac PowerPC G5 using AMD64 core (2005) DEC VAX (1977) DEC VAX (1970) SPARC Enterprise M4000 Server (2007) Microso} Server (2012)

28 Calling Factorial move $a0, $v0 # save n to $a0 jal factorial # jump to factorial PC: 0x $sp 0x7ffffe1c word 1 No0ce Now :PC= 0x word 1 addi $sp, $sp, - 8 # Make space on stack. sw $ra, 0($sp) # Save return address. $sp 0x7ffffe14 0x x40007c

29 Loading Program User Text Segment [ ]..[ ] [ ] 8fa40000 lw $4, 0($29) ; 183: lw $a0 0($sp) # argc [ ] 27a50004 addiu $5, $29, 4 ; 184: addiu $a1 $sp 4 # argv [ ] 24a60004 addiu $6, $5, 4 ; 185: addiu $a2 $a1 4 # envp [ c] sll $2, $4, 2 ; 186: sll $v0 $a0 2 [ ] 00c23021 addu $6, $6, $2 ; 187: addu $a2 $a2 $v0 [ ] 0c jal 0x [main] ; 188: jal main [ ] nop ; 189: nop [ c] a ori $2, $0, 10 ; 191: li $v0 10 [ ] c syscall ; 192: syscall # syscall 10 (exit) [ ] 23bdfff8 addi $29, $29, - 8 ; 13: addi $sp, $sp, - 8 # Make space on stack. [ ] a~f0000 sw $31, 0($29) ; 14: sw $ra, 0($sp) # Save return address. [ c] ori $2, $0, 1 ; 16: li $v0, 1 # 0! = 1 [ ] beq $4, $0, 24 [zero- 0x ] [ ] afa40004 sw $4, 4($29) ; 19: sw $a0, 4($sp) # Save our argument. [ ] 2084ffff addi $4, $4, - 1 ; 20: addi $a0, $a0, - 1 # Calculate (n- 1)! [ c] 0c jal 0x [factorial]; 21: jal factorial # Result in v0. [ ] 8fa40004 lw $4, 4($29) ; 22: lw $a0, 4($sp) # Restore our argument. [ ] mul $2, $4, $2 ; 23: mul $v0, $a0, $v0 # n! = n * (n- 1)! [ ] 8~f0000 lw $31, 0($29) ; 25: lw $ra, 0($sp) # Restore return address. [ c] 23bd0008 addi $29, $29, 8 ; 26: addi $sp, $sp, 8 # Restore stack pointer. [ ] 03e00008 jr $31 ; 27: jr $ra # Return.

30 Actual Program [ ] 23bdfffc addi $29, $29, - 4 ; 36: addi $sp, $sp, - 4 # Make space on stack. [ ] a~f0000 sw $31, 0($29) ; 37: sw $ra, 0($sp) # Save return address. [ c] 3c lui $1, 4097 [prompt] ; 39: la $a0, prompt [ ] ori $4, $1, 0 [prompt] [ ] ori $2, $0, 4 ; 40: li $v0, 4 [ ] c syscall ; 41: syscall # Display prompt. [ c] ori $2, $0, 5 ; 43: li $v0, 5 [ ] c syscall ; 44: syscall # Get integer response. [ ] addu $4, $0, $2 ; 46: move $a0, $v0 # Call factorial functon. [ ] 0c jal 0x [factorial]; 47: jal factorial [ c] addu $4, $0, $2 ; 49: move $a0, $v0 [ ] ori $2, $0, 1 ; 50: li $v0, 1 [ ] c syscall ; 51: syscall # Print integer result. [ ] 3c lui $1, 4097 [endl] ; 53: la $a0, endl [ c] f ori $4, $1, 31 [endl] [ ] ori $2, $0, 4 ; 54: li $v0, 4 [ ] c syscall ; 55: syscall # Print endl. [ ] ori $2, $0, 0 ; 57: li $v0, 0 # Return zero. [ c] 8~f0000 lw $31, 0($29) ; 58: lw $ra, 0($sp) # Restore return address. [004000a0] 23bd0004 addi $29, $29, 4 ; 59: addi $sp, $sp, 4 # Restore stack pointer. [004000a4] 03e00008 jr $31 ; 61: jr $ra

31 Factorial (Case n=0) PC: 0x word 1 li $v0, 1 # 0! = 1 beqz $a0, zero # Special case for 0! sw $a0, 4($sp) # Save our argument. addi $a0, $a0, - 1 # Calculate (n- 1)! jal factorial # Result in v0. lw $a0, 4($sp) # Restore our argument. mul $v0, $a0, $v0 # n! = n * (n- 1)! zero: # 0x lw $ra, 0($sp) # Restore return address. addi $sp, $sp, 8 # Restore stack pointer. jr $ra # Return $sp $sp 0x7ffffe14 0x7ffffe1c 0x x40007c word 1 0x No0ce $ra = 0x c 0x40007c

32 Factorial (Case n=else number, say 5? ) PC: 0x word 1 li $v0, 1 # 0! = 1 beqz $a0, zero # Special case for 0! sw $a0, 4($sp) # Save our argument. addi $a0, $a0, - 1 # Calculate (n- 1)! jal factorial # Result in v0. lw $a0, 4($sp) # Restore our argument. mul $v0, $a0, $v0 # n! = n * (n- 1)! zero: # 0x lw $ra, 0($sp) # Restore return address. addi $sp, $sp, 8 # Restore stack pointer. jr $ra # Return $sp $sp 0x7ffffe14 0x7ffffe1c 0x x40007c word 1 0x Now $a0 = 4, Then we jump to do factorial again! ~~~ 5 0x40007c

33 Factorial will finish un0l $a0 = 0 Now $a0 = 1, which is our n $v0 = $a0*$v0= 1*1 = 1 Then we restore return address by adding sp = sp + 8, and then do the same thing again by using jr $ra PC: 0x word 1 0x x40007c 4 0x40007c 3 0x40007c word 1 0x x40007c 4 0x40007c 3 0x40007c li $v0, 1 # 0! = beqz $a0, zero # Special case for 0! 0x40007c 0x40007c sw $a0, 4($sp) # Save our argument. addi $a0, $a0, - 1 # Calculate (n- 1)! 1 1 jal factorial # Result in v0. lw $a0, 4($sp) # Restore our argument. 0x40007c 0x40007c mul $v0, $a0, $v0 # n! = n * (n- 1)! 0 zero: # 0x lw $ra, 0($sp) # Restore return address. 0x40007c 0x40007c addi $sp, $sp, 8 # Restore stack pointer. jr $ra # Return $sp 0x7ffffdf8

34 I/O Management(Courtesy of Dr. Nhut Nguyen) In modern computer systems I/O opera0ons are mediated by the OS I/O opera0ons Mul0ple programs share I/O resources Need protec0on and scheduling I/O causes asynchronous interrupts Same mechanism as excep0ons I/O programming is fiddly OS provides abstrac0ons to programs

35 I/O Commands I/O devices are managed by I/O controller hardware Transfers data to/from device Synchronizes opera0ons with so}ware Command registers Cause device to do something Status registers Indicate what the device is doing and occurrence of errors Data registers Write: transfer data to a device Read: transfer data from a device

36 How To Operate on I/O Registers? Memory mapped I/O Registers are addressed in same space as memory Address decoder dis0nguishes between them OS uses address transla0on mechanism to make them only accessible to kernel Example: MIPS I/O instruc0ons and I/O ports Separate instruc0ons to access I/O ports Can only be executed in kernel mode Example: x86 (IN and OUT instruc0ons on I/O segment)

37 When to Perform I/O Opera0ons? Easy Way - Polling Periodically check I/O status register If device ready, do opera0on If error, take ac0on Common in small or low- performance real0me embedded systems Predictable 0ming Low hardware cost In other systems, wastes CPU 0me

38 When to Perform I/O Opera0ons? Be er Way - Interrupts When a device is ready or error occurs Controller interrupts CPU Interrupt is like an excep0on But not synchronized to instruc0on execu0on Can invoke handler between instruc0ons Cause informa0on o}en iden0fies the interrup0ng device Priority interrupts Devices needing more urgent a en0on get higher priority A higher priority I/O device can interrupt handler for a lower priority I/O device

39 I/O Data Transfer How? Programmed I/O CPU transfers data between memory and I/O data registers Time consuming for high- speed devices Direct memory access (DMA) OS provides star0ng address in memory I/O controller transfers to/from memory autonomously Controller interrupts on comple0on or error

40 MIPS- Memory- Mapped I/O The MIPS I/O address space 0xffff0000 to 0xffffffff is reserved for memory- mapped I/O How large is the I/O address space? Any address in this space can be mapped to I/O registers (command, status, data) of an I/O device I/O is performed using the regular load and store instruc?ons on these addresses e.g. li $t0, 0xffff0004 lw $s1, ($t0)

41 MIPS I/O Example MIPS CPU 0x xfffeffff Main Memory 0xffff0000 0xffff0004 0xffff0008 0xffff000c Interrupt Enable Ready Receiver Control Keyboard Receiver Data Transmitter Control Display Transmitter Data 8 bits

42 Keyboard & Display Controller Keyboard Control 0xFFFF bits Keyboard Data 0xFFFF bits Display Control 0xFFFF bits Display Data 0xFFFF000C 8 bits

43 Computer Buses A number of buses are in widespread use in the computer world. Mul0bus (8086) IBM PC (PC/XT) ISA bus (PC/AT) EISA bus (80386) Microchannel (PS/2) PCI bus (Many PCs) Nubus (macintosh) Universal Serial Bus (modern PCs) FireWire (consumer electronics)

QtSPIM and MARS : MIPS Simulators

QtSPIM and MARS : MIPS Simulators QtSPIM and MARS : MIPS Simulators Learning MIPS & SPIM MIPS assembly is a low-level programming language The best way to learn any programming language is to write code We will get you started by going

More information

Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #7. Warehouse Scale Computer

Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #7. Warehouse Scale Computer CS 61C: Great Ideas in Computer Architecture Everything is a Number Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13 9/19/13 Fall 2013 - - Lecture #7 1 New- School Machine Structures

More information

Lecture 5: Procedure Calls

Lecture 5: Procedure Calls Lecture 5: Procedure Calls Today s topics: Procedure calls and register saving conventions 1 Example Convert to assembly: while (save[i] == k) i += 1; i and k are in $s3 and $s5 and base of array save[]

More information

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture COMP 303 Computer Architecture Lecture 3 Comp 303 Computer Architecture 1 Supporting procedures in computer hardware The execution of a procedure Place parameters in a place where the procedure can access

More information

Lectures 5. Announcements: Today: Oops in Strings/pointers (example from last time) Functions in MIPS

Lectures 5. Announcements: Today: Oops in Strings/pointers (example from last time) Functions in MIPS Lectures 5 Announcements: Today: Oops in Strings/pointers (example from last time) Functions in MIPS 1 OOPS - What does this C code do? int foo(char *s) { int L = 0; while (*s++) { ++L; } return L; } 2

More information

CENG3420 Lecture 03 Review

CENG3420 Lecture 03 Review CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less

More information

CS 61C: Great Ideas in Computer Architecture Strings and Func.ons. Anything can be represented as a number, i.e., data or instruc\ons

CS 61C: Great Ideas in Computer Architecture Strings and Func.ons. Anything can be represented as a number, i.e., data or instruc\ons CS 61C: Great Ideas in Computer Architecture Strings and Func.ons Instructor: Krste Asanovic, Randy H. Katz hdp://inst.eecs.berkeley.edu/~cs61c/sp12 Fall 2012 - - Lecture #7 1 New- School Machine Structures

More information

CS 61C: Great Ideas in Computer Architecture Func%ons and Numbers

CS 61C: Great Ideas in Computer Architecture Func%ons and Numbers CS 61C: Great Ideas in Computer Architecture Func%ons and Numbers 9/11/12 Instructor: Krste Asanovic, Randy H. Katz hcp://inst.eecs.berkeley.edu/~cs61c/sp12 Fall 2012 - - Lecture #8 1 New- School Machine

More information

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Overview Last Lecture s Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a

More information

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points)

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points) ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points) Objectives: Get familiar with MIPS instructions Assemble, execute and debug MIPS

More information

MIPS Assembly Language Programming

MIPS Assembly Language Programming MIPS Assembly Language Programming ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals [Adapted

More information

MIPS function continued

MIPS function continued MIPS function continued Review Functions Series of related instructions one after another in memory Called through the jal instruction Pointed to by a label like any other Returns by calling Stack Top

More information

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009 Topic Notes: MIPS Programming We spent some time looking at the MIPS Instruction Set Architecture. We will now consider

More information

MIPS Processor Overview

MIPS Processor Overview MIPS Processor Cptr280 Dr Curtis Nelson MIPS Processor Overview Hardware Design philosophy Architecture Software Assembly language program structure QTSpim simulator Example programs 1 MIPS Processor Power

More information

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization CSE2021 Computer Organization Chapter 2: Part 2 Procedure Calling Procedure (function) performs a specific task and return results to caller. Supporting Procedures Procedure Calling Calling program place

More information

Lecture 5. Announcements: Today: Finish up functions in MIPS

Lecture 5. Announcements: Today: Finish up functions in MIPS Lecture 5 Announcements: Today: Finish up functions in MIPS 1 Control flow in C Invoking a function changes the control flow of a program twice. 1. Calling the function 2. Returning from the function In

More information

Lecture 5: Procedure Calls

Lecture 5: Procedure Calls Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record

More information

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero 25 Comparisons Set on less than (slt) compares its source registers

More information

MIPS Functions and the Runtime Stack

MIPS Functions and the Runtime Stack MIPS Functions and the Runtime Stack COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

MIPS Assembly Language Programming

MIPS Assembly Language Programming MIPS Assembly Language Programming COE 308 Computer Architecture Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline Assembly

More information

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) ELEC 5200-001/6200-001 Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) Victor P. Nelson, Professor & Asst. Chair Vishwani D. Agrawal, James J. Danaher Professor Department

More information

Chapter 2A Instructions: Language of the Computer

Chapter 2A Instructions: Language of the Computer Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction

More information

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont ) Chapter 2 Computer Abstractions and Technology Lesson 4: MIPS (cont ) Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left >>> srl Bitwise

More information

2012 David Black- Schaffer 1

2012 David Black- Schaffer 1 1 Instruc*on Set Architectures 2 Introduc

More information

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015 Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative

More information

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei Computer Architecture Instruction Set Architecture part 2 Mehran Rezaei Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a MIPS Interpreter

More information

Functions in MIPS. Functions in MIPS 1

Functions in MIPS. Functions in MIPS 1 Functions in MIPS We ll talk about the 3 steps in handling function calls: 1. The program s flow of control must be changed. 2. Arguments and return values are passed back and forth. 3. Local variables

More information

Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University. See P&H 2.8 and 2.12, and A.

Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University. See P&H 2.8 and 2.12, and A. Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See P&H 2.8 and 2.12, and A.5 6 compute jump/branch targets memory PC +4 new pc Instruction Fetch

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture MIPS Instruction Formats July 2, 2014 Review New registers: $a0-$a3, $v0-$v1, $ra, $sp New instructions: slt, la, li, jal, jr Saved registers: $s0-$s7, $sp, $ra Volatile registers: $t0-$t9, $v0-$v1, $a0-$a3

More information

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI. CSCI 402: Computer Architectures Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI Recall Big endian, little endian Memory alignment Unsigned

More information

Lecture 4: Instruction Set Architecture

Lecture 4: Instruction Set Architecture Lecture 4: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation Reading: Textbook (5 th edition) Appendix A Appendix B (4 th edition)

More information

MIPS and QTSPIM Recap. MIPS Architecture. Cptr280. Dr Curtis Nelson. Cptr280, Autumn

MIPS and QTSPIM Recap. MIPS Architecture. Cptr280. Dr Curtis Nelson. Cptr280, Autumn MIPS and QTSPIM Recap Cptr280 Dr Curtis Nelson MIPS Architecture The MIPS architecture is considered to be a typical RISC architecture Simplified instruction set Programmable storage 32 x 32-bit General

More information

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 MIPS Intro II Lect 10 Feb 15, 2008 Adapted from slides developed for: Mary J. Irwin PSU CSE331 Dave Patterson s UCB CS152 M230 L10.1

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 6: Procedures Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Procedures have different names in different languages Java:

More information

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls Announcements HW1 is due on this Friday (Sept 12 th ) Appendix A is very helpful to HW1. Check out system calls on Page A-48. Ask TA (Liquan chen: liquan@ece.rutgers.edu) about homework related questions.

More information

Code Genera*on for Control Flow Constructs

Code Genera*on for Control Flow Constructs Code Genera*on for Control Flow Constructs 1 Roadmap Last *me: Got the basics of MIPS CodeGen for some AST node types This *me: Do the rest of the AST nodes Introduce control flow graphs Scanner Parser

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

More information

Computer Architecture. MIPS Instruction Set Architecture

Computer Architecture. MIPS Instruction Set Architecture Computer Architecture MIPS Instruction Set Architecture Instruction Set Architecture An Abstract Data Type Objects Registers & Memory Operations Instructions Goal of Instruction Set Architecture Design

More information

CSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements

CSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements CSE141: Introduction to Computer Architecture CSE 141 Computer Architecture Spring 2005 Lecture 3 Instruction Set Architecute Pramod V. Argade April 4, 2005 Instructor: TAs: Pramod V. Argade (p2argade@cs.ucsd.edu)

More information

Computer Systems and Networks

Computer Systems and Networks LECTURE 16: MIPS (11 AND 12) Computer Systems and Networks Dr. Pallipuram (vpallipuramkrishnamani@pacific.edu) University of the Pacific Deadline Lab 11 is open: DUE 1 st NOV 5 AM Lab 12 is open: DUE 8

More information

ECE 250 / CS 250 Computer Architecture. Procedures

ECE 250 / CS 250 Computer Architecture. Procedures ECE 250 / CS 250 Computer Architecture Procedures Benjamin Lee Slides based on those from Alvin Lebeck, Daniel Sorin, Andrew Hilton, Amir Roth, Gershon Kedem Today s Lecture Admin HW #2 is up, due Sunday

More information

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology Computer Organization MIPS Architecture Department of Computer Science Missouri University of Science & Technology hurson@mst.edu Computer Organization Note, this unit will be covered in three lectures.

More information

CS 351 Exam 2 Mon. 11/2/2015

CS 351 Exam 2 Mon. 11/2/2015 CS 351 Exam 2 Mon. 11/2/2015 Name: Rules and Hints The MIPS cheat sheet and datapath diagram are attached at the end of this exam for your reference. You may use one handwritten 8.5 11 cheat sheet (front

More information

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 MIPS/SPIM General Purpose Registers Powers of Two 0 $zero all bits are zero 16 $s0 local variable 1 $at assembler temporary 17 $s1 local

More information

Course Administration

Course Administration Fall 2017 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture 2/4 Avinash Kodi Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701 E-mail: kodi@ohio.edu

More information

Function Calling Conventions 1 CS 64: Computer Organization and Design Logic Lecture #9

Function Calling Conventions 1 CS 64: Computer Organization and Design Logic Lecture #9 Function Calling Conventions 1 CS 64: Computer Organization and Design Logic Lecture #9 Ziad Matni Dept. of Computer Science, UCSB Lecture Outline More on MIPS Calling Convention Functions calling functions

More information

Today. Putting it all together

Today. Putting it all together Today! One complete example To put together the snippets of assembly code we have seen! Functions in MIPS Slides adapted from Josep Torrellas, Craig Zilles, and Howard Huang Putting it all together! Count

More information

MIPS Assembly Language. Today s Lecture

MIPS Assembly Language. Today s Lecture MIPS Assembly Language Computer Science 104 Lecture 6 Homework #2 Midterm I Feb 22 (in class closed book) Outline Assembly Programming Reading Chapter 2, Appendix B Today s Lecture 2 Review: A Program

More information

COE608: Computer Organization and Architecture

COE608: Computer Organization and Architecture Add on Instruction Set Architecture COE608: Computer Organization and Architecture Dr. Gul N. Khan http://www.ee.ryerson.ca/~gnkhan Electrical and Computer Engineering Ryerson University Overview More

More information

MIPS%Assembly% E155%

MIPS%Assembly% E155% MIPS%Assembly% E155% Outline MIPS Architecture ISA Instruction types Machine codes Procedure call Stack 2 The MIPS Register Set Name Register Number Usage $0 0 the constant value 0 $at 1 assembler temporary

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 15: Midterm 1 Review Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Basics Midterm to cover Book Sections (inclusive) 1.1 1.5

More information

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats Today s Lecture Homework #2 Midterm I Feb 22 (in class closed book) MIPS Assembly Language Computer Science 14 Lecture 6 Outline Assembly Programming Reading Chapter 2, Appendix B 2 Review: A Program Review:

More information

Processor design - MIPS

Processor design - MIPS EASY Processor design - MIPS Q.1 What happens when a register is loaded? 1. The bits of the register are set to all ones. 2. The bit pattern in the register is copied to a location in memory. 3. A bit

More information

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 101 Assembly ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 What is assembly? 79 Why are we learning assembly now? 80 Assembly Language Readings: Chapter 2 (2.1-2.6, 2.8, 2.9, 2.13, 2.15), Appendix

More information

Computer Architecture

Computer Architecture Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers

More information

Implementing Procedure Calls

Implementing Procedure Calls 1 / 39 Implementing Procedure Calls February 18 22, 2013 2 / 39 Outline Intro to procedure calls Caller vs. callee Procedure call basics Calling conventions The stack Interacting with the stack Structure

More information

instructions aligned is little-endian

instructions aligned is little-endian MEMÓRIA Data Types These instructions load and store aligned data: Load word (lw) Load halfword (lh) Load halfword unsigned (lhu) Load byte (lb) Load byte unsigned (lbu) Store word (sw) Store halfword

More information

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats Instructor: Justin Hsia 6/27/2012 Summer 2012 Lecture #7 1 Review of Last Lecture New registers: $a0-$a3, $v0-$v1, $ra, $sp Also: $at,

More information

MIPS Datapath. MIPS Registers (and the conventions associated with them) MIPS Instruction Types

MIPS Datapath. MIPS Registers (and the conventions associated with them) MIPS Instruction Types 1 Lecture 08 Introduction to the MIPS ISA + Procedure Calls in MIPS Longer instructions = more bits to address registers MIPS Datapath 6 bit opcodes... 2 MIPS Instructions are 32 bits More ways to address

More information

Lecture 7: Examples, MARS, Arithmetic

Lecture 7: Examples, MARS, Arithmetic Lecture 7: Examples, MARS, Arithmetic Today s topics: More examples MARS intro Numerical representations 1 Dealing with Characters Instructions are also provided to deal with byte-sized and half-word quantities:

More information

Exceptions and Interrupts

Exceptions and Interrupts Exceptions and Interrupts Unexpected events (asynchronous interrupt) requiring change in flow of control (different ISAs use the terms differently) exception Arises within the CPU e.g., undefined opcode,

More information

Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions

Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture The Instructions 1 1 Topics: Assembly language, assemblers MIPS R2000 Assembly language Instruction set

More information

Function Calls. 1 Administrivia. Tom Kelliher, CS 240. Feb. 13, Announcements. Collect homework. Assignment. Read

Function Calls. 1 Administrivia. Tom Kelliher, CS 240. Feb. 13, Announcements. Collect homework. Assignment. Read Function Calls Tom Kelliher, CS 240 Feb. 13, 2002 1 Administrivia Announcements Collect homework. Assignment Read 3.7 9. From Last Time SPIM lab. Outline 1. Function calls: stack execution model, memory

More information

Assembly labs start this week. Don t forget to submit your code at the end of your lab section. Download MARS4_5.jar to your lab PC or laptop.

Assembly labs start this week. Don t forget to submit your code at the end of your lab section. Download MARS4_5.jar to your lab PC or laptop. CSC258 Week 10 Logistics Assembly labs start this week. Don t forget to submit your code at the end of your lab section. Download MARS4_5.jar to your lab PC or laptop. Quiz review A word-addressable RAM

More information

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions Representing Instructions Instructions are encoded in binary Called machine code MIPS instructions Encoded as 32-bit instruction words Small number of formats encoding operation code (opcode), register

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-09 In Class Example Handout Part A: A Simple, MIPS-based Procedure: Swap Procedure Example: Let s write the MIPS code for the following statement (and function call): if (A[i] > A

More information

CSE 378 Midterm 2/12/10 Sample Solution

CSE 378 Midterm 2/12/10 Sample Solution Question 1. (6 points) (a) Rewrite the instruction sub $v0,$t8,$a2 using absolute register numbers instead of symbolic names (i.e., if the instruction contained $at, you would rewrite that as $1.) sub

More information

ECE 30 Introduction to Computer Engineering

ECE 30 Introduction to Computer Engineering ECE 30 Introduction to Computer Engineering Study Problems, Set #4 Spring 2015 Note: To properly study and understand the problems below, it is strongly recommended to implement and run your solution (and/or

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 2: Hardware/Software Interface Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Basic computer components How does a microprocessor

More information

Instruction Set Architectures Part I: From C to MIPS. Readings:

Instruction Set Architectures Part I: From C to MIPS. Readings: Instruction Set Architectures Part I: From C to MIPS Readings: 2.1-2.14 1 Goals for this Class Understand how CPUs run programs How do we express the computation the CPU? How does the CPU execute it? How

More information

The plot thickens. Some MIPS instructions you can write cannot be translated to a 32-bit number

The plot thickens. Some MIPS instructions you can write cannot be translated to a 32-bit number The plot thickens Some MIPS instructions you can write cannot be translated to a 32-bit number some reasons why 1) constants are too big 2) relative addresses are too big 3) absolute addresses are outside

More information

Lecture 6: Assembly Programs

Lecture 6: Assembly Programs Lecture 6: Assembly Programs Today s topics: Procedures Examples Large constants The compilation process A full example 1 Procedures Local variables, AR, $fp, $sp Scratchpad and saves/restores, $fp Arguments

More information

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018 ECE 331 Hardware Organization and Design Professor Jay Taneja UMass ECE - jtaneja@umass.edu Discussion 3 2/8/2018 Study Jams Leader: Chris Bartoli Tuesday 5:30-6:45pm Elab 325 Wednesday 8:30-9:45pm Elab

More information

ECE 30 Introduction to Computer Engineering

ECE 30 Introduction to Computer Engineering ECE 30 Introduction to Computer Engineering Study Problems, Set #3 Spring 2015 Use the MIPS assembly instructions listed below to solve the following problems. arithmetic add add sub subtract addi add

More information

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention Subroutines Why we use subroutines more modular program (small routines, outside data passed in) more readable, easier to debug code reuse i.e. smaller code space Memory Usage A software convention stack

More information

SPIM S20: A MIPS R2000 Simulator

SPIM S20: A MIPS R2000 Simulator SPIM S20: A MIPS R2000 Simulator 1 th 25 the performance at none of the cost James R Larus larus@cswiscedu Computer Sciences Department University of Wisconsin Madison 1210 West Dayton Street Madison,

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-08 In Class Example Handout Part A: J-Type Example: If you look in your book at the syntax for j (an unconditional jump instruction), you see something like: e.g. j addr would seemingly

More information

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects

More information

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS The Microprocessor without Interlocked Pipeline Stages

More information

2) Using the same instruction set for the TinyProc2, convert the following hex values to assembly language: x0f

2) Using the same instruction set for the TinyProc2, convert the following hex values to assembly language: x0f CS2 Fall 28 Exam 2 Name: ) The Logisim TinyProc2 has four instructions, each using 8 bits. The instruction format is DR SR SR2 OpCode with OpCodes of for add, for subtract, and for multiply. Load Immediate

More information

The plot thickens. Some MIPS instructions you can write cannot be translated to a 32-bit number

The plot thickens. Some MIPS instructions you can write cannot be translated to a 32-bit number The plot thickens Some MIPS instructions you can write cannot be translated to a 32-bit number some reasons why 1) constants are too big 2) relative addresses are too big 3) absolute addresses are outside

More information

CS 61C: Great Ideas in Computer Architecture. MIPS Instruc,on Representa,on II. Dan Garcia

CS 61C: Great Ideas in Computer Architecture. MIPS Instruc,on Representa,on II. Dan Garcia CS 61C: Great Ideas in Computer Architecture MIPS Instruc,on Representa,on II Dan Garcia 1 Review of Last Lecture Simplifying MIPS: Define instruc?ons to be same size as data word (one word) so that they

More information

Computer Organization MIPS ISA

Computer Organization MIPS ISA CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization

More information

Instruction Set Architectures (4)

Instruction Set Architectures (4) Computer Architecture Week 06 Instruction Set Architectures (4) College of Information Science and Engineering Ritsumeikan University subroutines functions, procedures remember the next instruction s address

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 8: Procedures (cont d), Binary Numbers and Adders Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Review: Procedure Calling Steps

More information

CS 316: Procedure Calls/Pipelining

CS 316: Procedure Calls/Pipelining CS 316: Procedure Calls/Pipelining Kavita Bala Fall 2007 Computer Science Cornell University Announcements PA 3 IS out today Lectures on it this Fri and next Tue/Thu Due on the Friday after Fall break

More information

A crash course in MIPS assembly programming

A crash course in MIPS assembly programming A crash course in MIPS assembly programming Computer Architecture 1DT016 distance Fall 2017 http://xyx.se/1dt016/index.php Per Foyer Mail: per.foyer@it.uu.se 1 MIPS Our processor Microprocessor without

More information

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,

More information

Function Calls. Tom Kelliher, CS 220. Oct. 24, SPIM programs due Wednesday. Refer to homework handout for what to turn in, and how.

Function Calls. Tom Kelliher, CS 220. Oct. 24, SPIM programs due Wednesday. Refer to homework handout for what to turn in, and how. Function Calls Tom Kelliher, CS 220 Oct. 24, 2011 1 Administrivia Announcements Assignment SPIM programs due Wednesday. Refer to homework handout for what to turn in, and how. From Last Time Outline 1.

More information

EN164: Design of Computing Systems Lecture 11: Processor / ISA 4

EN164: Design of Computing Systems Lecture 11: Processor / ISA 4 EN164: Design of Computing Systems Lecture 11: Processor / ISA 4 Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown University

More information

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook) Lecture 2 Instructions: Language of the Computer (Chapter 2 of the textbook) Instructions: tell computers what to do Chapter 2 Instructions: Language of the Computer 2 Introduction Chapter 2.1 Chapter

More information

MIPS ISA-II: Procedure Calls & Program Assembly

MIPS ISA-II: Procedure Calls & Program Assembly MIPS ISA-II: Procedure Calls & Program Assembly Module Outline Reiew ISA and understand instruction encodings Arithmetic and Logical Instructions Reiew memory organization Memory (data moement) instructions

More information

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Procedure Calls A procedure of a subroutine is like an agent which needs certain information to perform a

More information

EN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design

EN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design EN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown

More information

Lecture 7: MIPS Functions Part 2. Nested Function Calls. Lecture 7: Character and String Operations. SPIM Syscalls. Recursive Functions

Lecture 7: MIPS Functions Part 2. Nested Function Calls. Lecture 7: Character and String Operations. SPIM Syscalls. Recursive Functions Part Part Part What if we need to call a function inside of a function? Will this work? int twofun(int a, int b) { int res; res = addfun(a, b) a / ; return res; } twofun: addi $sp, $sp, -4 sw $s0, 0($sp)

More information

ECE Exam I February 19 th, :00 pm 4:25pm

ECE Exam I February 19 th, :00 pm 4:25pm ECE 3056 Exam I February 19 th, 2015 3:00 pm 4:25pm 1. The exam is closed, notes, closed text, and no calculators. 2. The Georgia Tech Honor Code governs this examination. 3. There are 4 questions and

More information

Review Session 1 Fri. Jan 19, 2:15 pm 3:05 pm Thornton 102

Review Session 1 Fri. Jan 19, 2:15 pm 3:05 pm Thornton 102 Review Session 1 Fri. Jan 19, 2:15 pm 3:05 pm Thornton 102 1. Agenda Announcements Homework hints MIPS instruction set Some PA1 thoughts MIPS procedure call convention and example 1 2. Announcements Homework

More information

SPIM Instruction Set

SPIM Instruction Set SPIM Instruction Set This document gives an overview of the more common instructions used in the SPIM simulator. Overview The SPIM simulator implements the full MIPS instruction set, as well as a large

More information

MIPS Functions and Instruction Formats

MIPS Functions and Instruction Formats MIPS Functions and Instruction Formats 1 The Contract: The MIPS Calling Convention You write functions, your compiler writes functions, other compilers write functions And all your functions call other

More information

Computer Architecture. The Language of the Machine

Computer Architecture. The Language of the Machine Computer Architecture The Language of the Machine Instruction Sets Basic ISA Classes, Addressing, Format Administrative Matters Operations, Branching, Calling conventions Break Organization All computers

More information