Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.

Slides:



Advertisements
Similar presentations
Lecture 5: MIPS Instruction Set
Advertisements

Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Chapter 2 Instructions: Language of the Computer Part III.
CS2100 Computer Organisation MIPS Part III: Instruction Formats (AY2014/2015) Semester 2.
Chapter 2 : Number System
Data Representation Computer Organization &
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Data Representation COE 205
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
Instruction Representation I (1) Fall 2005 Lecture 05: INSTRUCTION REPRESENTATION.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
Simple Data Type Representation and conversion of numbers
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computers Organization & Assembly Language
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
IT253: Computer Organization
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
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.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization – Memory Access David Monismith Jan. 30, 2015 Based upon notes by Dr. Bill Siever and the Patterson and Hennessy Text.
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
SAK Chapter 21 Chapter 2 : Number System 2.1 Decimal, Binary, Octal and Hexadecimal Numbers 2.2 Relation between binary number system with other.
1 Information Representation in Computer Lecture Nine.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
CENG 311 Instruction Representation
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 9 Binary Representation and Logical Operations.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
David Kauchak CS 52 – Spring 2017
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
COMPUTER ARCHITECTURE & OPERATIONS I
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Morgan Kaufmann Publishers
Lecture 4: MIPS Instruction Set
Lesson objectives Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement)
Number Systems.
Computer Architecture & Operations I
CSCI206 - Computer Organization & Programming
Computer Architecture & Operations I
MIPS Instruction Encoding
MIPS Instruction Encoding
CS/COE0447 Computer Organization & Assembly Language
CS/COE0447 Computer Organization & Assembly Language
Chapter 6: Computer Arithmetic
Data Representation ICS 233
Presentation transcript:

Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text

Last Time We looked at base 2 or binary numbers. Let's look at some more examples of converting from decimal to binary to hex and vice versa.

Binary Conversion Given a decimal number, 576, convert it to binary. We do so by continuously taking thenumber modulo 2 and dividing that number in half using integer division. 576 % 2 = % 2 = % 2 = 0 72 % 2 = 0 36 % 2 = 0 18 % 2 = 0 9 % 2 = 1 4 % 2 = 0 2 % 2 = 0 1

Binary Conversion Then we read the binary number from bottom to top. And we can check by converting back to decimal b = 2^9 + 2^6 = = 576 What if we want to convert 576 to hex? First, convert it to binary, then divide the binary number into groups of four bits starting from the right

Binary Conversion Convert each of the groups of four bits to a hex number. Why does this work? Hex is base 16, and there are 16 possible values for four bits (2*2*2*2 = 16). Take home message: If you need to convert a decimal number to hexadecimal, convert the decimal number to binary first. Then, convert the binary number to hex.

Binary Addition What if we want to add two binary numbers? Take decimal numbers 5 and 3 and add them in binary. 101b is 5 decimal 11b is 3 decimal

Binary Addition Contd. Notice that there is a carry over bit. This can cause a problem called overflow. Notice that ifwe only have 3 bits to represent our numbers, we would have a result of zero. Take home message: be sure to use enough precision (enough bits) to deal with the numbers you are adding We also have to be careful with negative numbers. We could use a one or a zero to represent the sign bit. Let's assume we have 5 bits to workwith, and we try to add a positive and negative binary number. Let's use a leading one torepresent a negative number and a leading zero to represent a positive number b is -3 decimal 00101b is 5 decimal

Binary Addition Example <---- result is -8 (wrong) Our result should be 2 decimal. Notice that we need a different representation if we are going to directly add positive and negative numbers. In a few days we will look at a different representation of signed integers called 2’s complement representation. Before looking at 2's complement, we need to look at instruction formats.

MIPS Instructions MIPS instructions use 32 bits and come in 3 basic formats. R format instructions These are register format instructions. That is, they use only registers. R-format instructions use the following format: Opcode rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits Recall that instructions are 32-bit. Notice that 32 =

I format instructions These are immediate format instructions. These instructions utilize a 16-bit integer value. I-format instructions use the following format: Opcode rs rt immediate 6 bits 5 bits 5 bits 16 bits opcode - instruction type rt - often the destination register rs - often the source register immediate - a 16 bit integer value

Assembly Code Conversion How do we convert from assembly to machine code? Look at the green sheet in your textbook. There are codes present near each instruction. These codes are in hex. For R-format instructions, the opcode is listed first, then the function code You may ignore the shamt for now.

Example add $s1, $s2, $s5 On the green sheet, the Opcode/Funct is listed. For add it is 0 / 20_hex 0 hex in 6 bits is b - our opcode 20 hex in 6 bits is b - our function code So our values follow below: – opcode = b = 0x00 – dest register (rd) = $s1 = $17 --> 0x11 --> – source register 1 (rs) = $s2 = $18 --> 0x12 --> – source register 2 (rt) = $s5 = $21 --> 0x15 --> – function value =

Example The binary representation of add $s1, $s2, $s5 is: opcode rs rt rd shamt func We can easily convert this to hex by dividing our 32 bit instruction into sections of four bits and finding the hex value for each set of four bits > 0x

Recap Notice that we can now represent binary numbers in multiple ways. They could be an address, ASCII text, instructions (I or R format), a signed number, unsigned numbers, or floating point numbers. Instruction formats are an encoding that allows us to represent our instructions as numbers.