NAME: 1. (2) What is a transistor?

Similar documents
CS341l Fall 2009 Test #1

MIPS Instruction Reference

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

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

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

MIPS function continued

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

Lecture 5: Procedure Calls

Compiling Techniques

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

Control Instructions

CSE 2021: Computer Organization

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

Chapter 2. Instructions:

Architecture II. Computer Systems Laboratory Sungkyunkwan University

Homework 2 - Solutions (Assembly Language and Machine Language) Maximum points : 40 points

MIPS Reference Guide

1/26/2014. Previously. CSE 2021: Computer Organization. The Load/Store Family (1) Memory Organization. The Load/Store Family (2)

Reduced Instruction Set Computer (RISC)

ECE260: Fundamentals of Computer Engineering

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer

Common Problems on Homework

ECE 30 Introduction to Computer Engineering

Chapter 3. Instructions:

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

MIPS Instruction Set

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

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

M2 Instruction Set Architecture

CS61C Machine Structures. Lecture 12 - MIPS Procedures II & Logical Ops. 2/13/2006 John Wawrzynek. www-inst.eecs.berkeley.

F. Appendix 6 MIPS Instruction Reference

bits 5..0 the sub-function of opcode 0, 32 for the add instruction

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

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

Reduced Instruction Set Computer (RISC)

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

Previously. CSE 2021: Computer Organization. Memory Organization. The Load/Store Family (1) 5/26/2011. Used to transfer data to/from DRAM.

Lecture 6: Assembly Programs

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

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

ECE 15B Computer Organization Spring 2010

Q1: /30 Q2: /25 Q3: /45. Total: /100

CS 61c: Great Ideas in Computer Architecture

Thomas Polzer Institut für Technische Informatik

CSSE 232 Computer Architecture I. I/O and Addressing

EE 361 University of Hawaii Fall

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014

ECE 2035 Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 9 December 2013

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

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

CS 61c: Great Ideas in Computer Architecture

Computer Architecture. The Language of the Machine

CS3350B Computer Architecture MIPS Procedures and Compilation

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

CS/COE1541: Introduction to Computer Architecture

The MIPS Instruction Set Architecture

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

Examples of branch instructions

CS3350B Computer Architecture MIPS Instruction Representation

ECE331: Hardware Organization and Design

COMPUTER ORGANIZATION AND DESIGN

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

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations

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

Flow of Control -- Conditional branch instructions

MIPS Instruction Format

SPIM Instruction Set

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

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

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

Computer Architecture. MIPS Instruction Set Architecture

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

Lecture 7: Examples, MARS, Arithmetic

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

We will study the MIPS assembly language as an exemplar of the concept.

CS61C - Machine Structures. Lecture 6 - Instruction Representation. September 15, 2000 David Patterson.

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

MIPS%Assembly% E155%

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

Machine Instructions - II. Hwansoo Han

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013

CS3350B Computer Architecture

Computer Architecture

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

Chapter 2: Instructions:

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

MIPS Instruction Set Architecture (2)

Instructions: Assembly Language

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam 29 April 2015

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from:

Communicating with People (2.8)

Transcription:

NAME: CS3411 Test #1, 6 September 2007. You have 1h15min (one css period). Answer all questions. The number of points (out of 100) each problem is worth is shown in (parentheses). Be as concise as you can while still answering the question. 1. (2) What is a transistor? An electrical on/off switch 2. (2) What do we call the 32-bit value that we store for nested procedures that points to the instruction after the jal instruction that called a procedure, so that we can go back to the calling procedure? return address 3. (2) What do we call the register where the value from problem #2 is stored when we execute a jal? (Write it as it appears in MIPS code). $ra 4. (2) Where do we store that register (from problem #3) when we have nested procedures so that we can restore it before returning with a jr instruction (hint: it's not the heap)? the stack 5. (2) What register keeps track of the control flow and is used to calcute the 32-bit value for problem #2? (Write what we call it, not MIPS code). program counter

6. (10) Write what type of encoding (?-Type ) is used to encode each of the following MIPS instructions: add $t0 $t1 $t2 R j SomeLabel J jal SomeLabel J addi $t0 $t0 1 I slti $t8 $t7 'c' I sw $t0 8($t1) I sll $t6 $t8 5 R bneq$t5 $t7 SomeLabel I ori $t6 $t6 4 I addu$t0 $t1 $t2 R 7. (5) If I put together a single half adder and 31 full adders to create a 32- bit adder, what would I call this? Why do circuit designers often use more complex adders than this? Ripple Carrry Adder, the circuit dey is too long.

8. (10) For each of these addressing modes, give an example MIPS instruction that uses that type of addressing, and for those that have limitations on what addresses in a 32-bit address space they can address, state precisely what those limitations are. Register addressing add $t0 $t1 $2 Base or dispcement addressing lw $t0 0($t1) Immediate addressing addi $t0 $t1 55 PC-retive addressing bne $t0 $t1 SomeLabel can only branch about 2^15 words or 2^17 bytes in either direction. Pseudo-direct addressing jal SomeProcedure limited to a 256 MB block of memory

9. (10) Write down, for each transformation, what compiler optimization has occurred (examples are in MIPS assembly or C pseudocode of MIPS assembly): Before optimization After optimization What? for (i=0;i<4;i++) { x[i] = y[ 4- i] } addi $s3 $zero 32 multu $s2 $s3 mflo $s1 for (i=0;i<4;i+=2) { x[i] = y[4 i]; x[i + 1] = y[3 i]; } sll $s1 $s2 5 Loop Unrolling Strength Reduction i = 7 * 8 * 100; i = 5600; Constant Folding (or Constant Propagation) for (i=0;i<100;i++) { z = w * 4; x[i] = y[i] * z; } add $t1 $t2 $t3 beq $zero $zero LL: sub $t5 $t6 $t7 LL: sll $t1 $t1 4 z = w * 4; for (i=0;i<100;i++) { x[i] = y[i] * z; } add $t1 $t2 $t3 sll $t1 $t1 4 Code Motion Dead Code Elimination

10. (10) What is going to happen in each of these examples (underflow, overflow, something else)? How will we know (an exception, or do we need to check something in particur)? Assume that this is just pseudocode and we're actually writing these in MIPS and doing the checks afterward or handling thrown exceptions. a. float f; int i; for (i = 0; i < 1000; i++) f *= 0.5; Assuming I had initialized f, e.g. f = 1.0, then underflow, we'll get f == 0.0, no exception. b. unsigned int i = 0x80000000; i = i + i; Overflow, have to check both operands before the add. (No exception) c. unsigned int i = 0x80000000; i = i * 2; Overflow, have to use mfhi and check for non-zero after the multiply. (No exception) d. float f = 100.0; float g = 0.0; float h; h = f / g; Divide by zero, h == inf. (No exception) e. float f = 0.0; float g = 0.0; float h; h = f / g; Divide by zero, h == NaN. (No exception)

11. (30) Annotate the following MIPS code with comments about what is going on. Then write a single high-level sentence in English expining what the code does. Then write what the output of the program is..data s1:.asciiz "Hello123." s2:.asciiz "B876bb!" s3:.asciiz "55xyz66op88 333:/#7" s:.word 0.word 0.word 0.word 0 Output:.space 100.text.align 2 main: sw sw sw $t0 s1 $t1 s $t0 0($t1) $t0 s2 $t0 4($t1) $t0 s3 $t0 8($t1) $t3 Output addi $t1 $zero 0 Outer: sll $t7 $t1 2 $t8 s add $t7 $t7 $t8 lw $t0 0($t7) Inner: lb $t8 0($t0)

slti $t5 $t8 '0' slti $t6 $t8 ':' # ':' comes after '9' sub $t6 $t6 $t5 beq $t6 $zero There sb $t8 0($t3) addi $t3 $t3 1 There: addi $t0 $t0 1 bne $t8 $zero Inner addi $t1 $t1 1 sll $t7 $t1 2 $t8 s add $t7 $t7 $t8 lw $t8 0($t7) bne $t8 $zero Outer addi $t8 $zero 10 # 10 == new line sb $t8 0($t3) sb $zero 1($t3) $a0 Output li $v0 4 syscall jr $ra # write_string(output) 10 points (number on top) if you basically knew what a pointer was and demonstrated that by annotating, etc. 10 points (middle number) if you knew basic ops like add and sll, 10 points if you understood at a high level what was going on, even if you didn't get the output right.

12. (10) Count the total number of basic blocks in the program from problem #11. How many basic blocks are there? Eight. Remember that we're considering syscall to be the end of a basic block. 13. (5) In problem #11, the assembler is going to put instructions in memory in not quite the same order as the assembly code has them. Why? Deyed branch (Your answer for #13 should end about here, no need to write an essay because the rest of the page is bnk. In fact, if you know the two-word name for it, just write those two words.)