1. Integer to ASCII string

Slides:



Advertisements
Similar presentations
Lecture 5: MIPS Instruction Set
Advertisements

CS 136 Lab 2 MIPS ISA SPIM. Prob 2.30 sll $a2, $a2, 2 sll $a3, $a3, 2 add $v0, $zero, $zero add $t0, $zero, $zero outer:add $t4, $a0, $t0 lw $t4, 0($t4)
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
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.
Solution 2nd Exam.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
MIPS Function Continued
The University of Adelaide, School of Computer Science
Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.
Lecture 15: Computer Arithmetic Today’s topic –Division 1.
CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©
Lecture Objectives: 1)Perform binary division of two numbers. 2)Define dividend, divisor, quotient, and remainder. 3)Explain how division is accomplished.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
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.
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Solutions and Examples or $t0, $zero, $zero# i = 0 li $t1, 101# $t1 = 101 for:beq $t0, $t1, exit# if (i==101) exit add $t2, $t0, $a1 lw $s1, 0($t2)#
1 Lecture 15: Recap Today’s topics:  Recap for mid-term Reminders:  no class Thursday  office hours on Monday (10am-4pm)  mid-term Tuesday (arrive.
Integer Multiplication and Division
1 CS 430 Computer Architecture Clap if you like pizza! Pointless Poll.
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
Binary Numbers.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Ellen Spertus MCS 111 October 11, 2001 Floating Point Arithmetic.
Lecture 9: Floating Point
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:
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Integer Multiplication and Division
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.
Restoring Unsigned Integer Division
Computer Organization Instructions Language of The Computer (MIPS) 2.
Division. Just as multiplication can be expressed as a series of additions, division can be seen as a series of subtractions. 21 ÷ 7 asks how many times.
Division Check for 0 divisor Long division approach – If divisor ≤ dividend bits 1 bit in quotient, subtract – Otherwise 0 bit in quotient, bring down.
Pseudo instructions. MIPS supports pseudo instructions. We have seen some like – li $t0, 4 which set $t0 to 4. – la $t0, A which puts the address of label.
CDA 3101 Spring 2016 Introduction to Computer Organization
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic6: Logic, Multiply and Divide Operations José Nelson Amaral.
Lab 7. Given: Two’s complement integer A single precision floating-point.
Unit 1 Rational Numbers Integers.
COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD.
Integer Multiplication and Division
Morgan Kaufmann Publishers Arithmetic for Computers
Computer Organization and Design Instruction Sets - 2
Negative Numbers.
Computer Architecture & Operations I
Computer Organization and Design Instruction Sets - 2
Lecture 8: Binary Multiplication & Division
Pseudo instructions.
CDA 3101 Summer 2007 Introduction to Computer Organization
Computer Organization and Design Instruction Sets
The University of Adelaide, School of Computer Science
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
SPIM Syscalls.
Test 1 Review Lectures 1-5.
MISP Assembly.
Solutions Chapter 2.
ECE232: Hardware Organization and Design
MIPS assembly.
Square Least number Add & Subtract.
Pointless Poll Clap if you like pizza!.
MIPS Arithmetic and Logic Instructions
MIPS instructions.
Conditional Branching (beq)
Presentation transcript:

1. Integer to ASCII string For example, if $a0 = 0000002A, which is 101010two=42ten, then $a1 = 00003234 addi $t0, $zero, 10 div $a0, $t0 # $a0/10 mflo $a1 # $a1 = quotient addi $a1, $a1, 0x30 # convert to ASCII mfhi $t0 # $t0 = remainder addi $t0, $t0, 0x30 # convert to ASCII sll $t0, $t0, 8 or $a1, $a1, $t0

2. Integer Division See 3.27 solution

3. MIPS Instruction addi $a1, $zero, 32 loop: addi $a1, $a1, -4 lw $a0, 8($a1) beq $a1, $zero, exit j loop exit 70000000 70000004 70000008 7000000C 70000010 70000014 001000 00000 00101 0000 0000 0010 0000 1111 1111 1111 1100 100011 00100 0000 0000 0000 1000 000100 0000 0000 0000 0001 000010 0000 0000 0000 0000 0000 0000 01

4. Floating-Point (0.3)oct=3/8 1100 0000 0010 1100 0000 0000 0000 0000 1*8513-511*0.011=64*(1/4+1/8)=24 Smallest number > 8-512*2-22 >10-600 Why no hidden bit? For base 2, we can always normalize to 1.M*2e. For example, (0.1)two = (1.0)two*21, (0.01)two= (1.0)two*22, (0.001)two = (1.0)two*23 For base 8, it is not always possible to normalize to 1.M*8e. For example, (0.1)two=(0.1)two*80=(100.0)two*8, (0.01)two=(0.01)two*80=(10.0)two*81 For any base other than 2, there can not be any hidden bit.

5. Questions Booths algorithm: See 00, 11 do nothing See 01, addition See 10, subtraction Best if 11111111111…, 1 add, 1 sub Worst if 101010101…, 16 add, 16 sub

Speedup 2 hours from CLL to AUS 4 hours from AUS to LAX, 1200 miles Total 6 hours Speedup 2, meaning 3 hours Alternative answer (assume perm between AUS and LAX) 1 hour from AUS to LAX => 1200/hour Total 4 hours 2 hours from AUS to LAX => 600/hour

b) MIPS Convert beq $a0, 0x1234abcd, exit Answer: lui $at, 0x1234 ori $at, $at, 0xabcd beq $a0, $at, exit

e) Floating-Point Associative Operation ? is associative if a?(b?c) = (a?b)?c For example, + and * is associate What about division? 3/(4/5)=(3/4)/5? No! FP addition: a+(b+c)=(a+b)+c? 10^1000+(-10^1000+1)=0 (10^1000-10^1000)+1=1

Example: Avoid FP error To compute the average age for all people in USA Method 1: Add age of all people into total Compute total/295,000,000 Method 2: Compute average age for each group of 1,000 people Compute the average of every 1,000 groups Compute the average of the 295 averages Which method produces more accurate result?