1 Answers to Test 1, Question 1 The function determines if the number is divisible by 6. It performs this by dividing the number first by 3 and then by.

Slides:



Advertisements
Similar presentations
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Advertisements

Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
Solution 2nd Exam.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
Chapter 3 Arithmetic for Computers. Exam 1 CSCE
Assembly Code Example Selection Sort.
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
Assembly Language Working with the CPU.
Lecture 8: MIPS Instruction Set
1 Review Chpt 2 and 3 Five components of a computer Input Output Memory Arithmetic & Logic Unit (ALU) Control Two types of information Data and instruction.
1 Quiz 3, Answers 1,3 The CPI is: 0.22* * * *12 = = 5.42 In the 2nd case the CPI is 1.0. Every instruction.
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
Structured Program Modular structure Program grouped into blocks, each performing one task Clear interface between blocks, Easy to write, read, debug and.
1 CS 430 Computer Architecture Clap if you like pizza! Pointless Poll.
1. Integer to ASCII string
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
1 Answers to Test 2, Question 1 The functions receives the radius and height of a cylinder (גליל) and returns its volume (נפח). const float PI=3.14 float.
1 Answers to Test 1, Question 1 The functions determines if a positive number is prime. It does this by checking if the number is lower than 4, if so it.
Lecture 5: Procedures. Function call book-keeping in C main() { int i,j,k,m;... i = mult(j,k);... m = mult(i,i);... } /* really dumb mult function */
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
In Class Execise. .data A:.word 0,1,2,3,4,5,6,7,8,9.text.globl main main: la $a0,A li $a1,6 li $a2,5 jal onUpStream done: li $v0, 10# exit syscall onUpStream:
Lecture 8. MIPS Instructions #3 – Branch Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 21 Today’s class More assembly language programming.
True Assembly Language Part I. The Assembly Process The process of translating a MAL code (an assembly language program) into machine code (a sequence.
Computer Organization Instructions Language of The Computer (MIPS) 2.
MIPS Assembly Language Chapter 13 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
CDA 3101 Spring 2016 Introduction to Computer Organization
The Assembly Process Computer Organization and Assembly Language: Module 10.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
COSC 3330/6308 Second Review Session Fall Instruction Timings For each of the following MIPS instructions, check the cycles that each instruction.
COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD.
Control Structures Computer Organization I 1 October 2009 © McQuain, Feng & Ribbens Conditional Control Structure if ( i < j ) goto A; else.
CPEG323 Homework Review I Long Chen October, 17 th, 2005.
/ Computer Architecture and Design
Computer Architecture & Operations I
CSCI206 - Computer Organization & Programming
CS2100 Computer Organization
Computer Architecture & Operations I
Computer Organization and Design Instruction Sets - 2
ELEN 468 Advanced Logic Design
Computer Organization and Design Instruction Sets - 2
Morgan Kaufmann Publishers
/ Computer Architecture and Design
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
Pseudo instructions.
Computer Organization and Design Instruction Sets
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
CSCI206 - Computer Organization & Programming
CSCI206 - Computer Organization & Programming
Set-Associative Cache
Addressing in Jumps jump j Label go to Label op address 2 address
ECE232: Hardware Organization and Design
CSCI206 - Computer Organization & Programming
Review.
The University of Adelaide, School of Computer Science
Flow of Control -- Conditional branch instructions
March 27 Test 2 Review Read Sections 5.1 through 5.3.
MIPS Coding.
Flow of Control -- Conditional branch instructions
Generalities for Assembly Language
Pointless Poll Clap if you like pizza!.
9/27: Lecture Topics Memory Data transfer instructions
Caches & Memory.
Conditional Branching (beq)
Presentation transcript:

1 Answers to Test 1, Question 1 The function determines if the number is divisible by 6. It performs this by dividing the number first by 3 and then by 2. If they divide without remainder the number is divisible by 6. int div6(int n){ if(n%3 != 0) return 0; if(n%2 != 0) return 0; return 1; }

2 Question 2 A single precision floating point number is composed of: –1 bit sign (bit 31) –8 bit exponent (bits 23-30) –23 bit mantissa (bits 0-22) A double precision floating point number is composed of: –1 bit sign (bit 63) –11 bit exponent (bits 52-62) –52 bit mantissa (bits 0-51)

3 Question 3 ET A = 135M * 2.9 * 1.5ns = 587M ns = sec ET B = 125M *2.2 *(1/450M)ns = 611M ns = s A is faster than B by 4% (611/587) Computer A: FE=1.00 (all the instructions are effected), SE = 135/125 = (1.00/ )*0.587 = sec Computer B: FE=0.40, SE=2.2/1.7 = 1.29 (0.40/ )*0.611 = sec A is still faster this time by 556/543 = 1.024

4 Question 4 Mapping an address into a cache is done by: 1. Computing the block address of the address. Dividing the address into the number of words in each block. 2. Finding the cache location by computing the block address modulo (%) the number of blocks in the cache. 3. The offset of the word in the block, is the remainder of step 1. To get the block address of each address we have to divide by the number of words in the block, which is 1. This number modulo 16 is the cache block the address is mapped to. The only hits are the last accesses to 5, 9, and 17. All the other accesses are misses, so the hit rate is 19%.

5 Question 4 (cont) If the block size is 4 we must divide each address by 4 to get the block address and then compute modulo 4. Now we have 1(m), 4(m), 8(m), 5(h), 20(m), 17(m), 19(h), 56(m), 9(m), 11(h), 4(m), 43(m), 5(h), 6(h), 9(m), 17(h). The hit rate is now 37%. For the 3 rd case the mapping is set address modulo number of sets. So each address has to be divided by 8 and then modulo 2 taken: 1(m), 4(m), 8(m), 5(h), 20(m), 17(m), 19(h), 56(m), 9(h), 11(h), 4(m), 43(m), 5(h), 6(h), 9(h), 17(h). The hit ratio is now 50%.

6 Question 5 If the block is less than bytes a bne can be used: bne $a0,$a1,End … End: If the block is larger than bytes a j must be used: beq $a0,$a1,L1 j End L1: … End:

7 Question 5 (cont) If the block spans a 256MB boundary j can't be used. Only jr can be used. The problem is getting the address in a register. Using lui or a shift operation can solve the problem: lui $t0,0xFFDD # li $t0,0xFFDD # sll $t0,$t0,16 addi $t0,$t0,0xCCAA beq $a0,$a1,L1 jr $t0 L1: … End:

8 Question 6 AMAT = 0.92* (0.88* *12) =2.448 Changing the hit-time of L1 to 1 leads to an AMAT of: 0.92* (0.88* *12) = Changing the hit-ratio of L2 to 99% leads to an AMAT of: 0.92* (0.97* *12) = Thus changing the hit-time of L1 is a better choice.

9 Question 7 swap: lw $t0,0($a0)# $t0 = *a lw $t1,0($a1)# $t1 = *b ble $t0,$t1,L1 # if $t0 <= $t1 branch sw $t1,0($a0) # *a = *b sw $t0,0($a1) # *b = *a L1: jr $ra # return

10 Question 8 mov $t0,$t1 -> add $t0,$t1,$zero li $t0,17 -> addi $t0,$zero,17 bne $t2,$zero,L1 mul $t0,$t1,$t2 -> mult $t1,$t2 mflo $t0 blt $t0,$t1,L1 -> slt $t2,$t0,$t1 bne $t2,$zero,L1