Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.

Slides:



Advertisements
Similar presentations
Goal: Write Programs in Assembly
Advertisements

Lecture 5: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer
ICS312 Set 2 Representation of Numbers and Characters.
Chapter 2 Instructions: Language of the Computer Part III.
CS2100 Computer Organisation MIPS Part III: Instruction Formats (AY2014/2015) Semester 2.
Instructions Set Bo Cheng Instruction Set Design An Instruction Set provides a functional description of a processor. It is the visible.
Data Representation Computer Organization &
Binary & Decimal numbers = 3* * *10 + 5*1 = 3* * * *10 0 Decimal system: Ten digits: 0,1,2,3,…,9 Example:
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Data Representation COE 205
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
The Processor 2 Andreas Klappenecker CPSC321 Computer Architecture.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
Instruction Representation I (1) Fall 2005 Lecture 05: INSTRUCTION REPRESENTATION.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
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.
Two’s Complement 1.As an action: (Assume the starting value is 1011) 1.Flip the bits from the starting value => Add one to get the answer.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Arithmetic for Computers
CMPT 334 Computer Organization
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Integer Representation and the ALU.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ICS312 Set 1 Representation of Numbers and Characters.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1.
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
Chapter 2 CSF 2009 The MIPS Assembly Language: Introduction to Binary System.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
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.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 9 Binary Representation and Logical Operations.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
Computer Organization 1 Data Representation Negative Integers.
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 Patternson and Hennessy Text.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
COMPUTER ARCHITECTURE & OPERATIONS I
Morgan Kaufmann Publishers
Lecture 4: MIPS Instruction Set
The University of Adelaide, School of Computer Science
Computer Architecture & Operations I
CS170 Computer Organization and Architecture I
Lecture 4: MIPS Instruction Set
The University of Adelaide, School of Computer Science
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
Computer Architecture & Operations I
MIPS Instruction Encoding
The University of Adelaide, School of Computer Science
MIPS Instruction Encoding
Chapter 2 Instructions: Language of the Computer
Instruction encoding The ISA defines Format = Encoding
Computer Architecture
Instruction encoding The ISA defines Format = Encoding
COMS 361 Computer Organization
Instruction encoding The ISA defines Format = Encoding
Instruction encoding The ISA defines Format = Encoding
CS334: Number Systems Lab 1.
Presentation transcript:

Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory 3)Understand the limitations of using sign and magnitude to represent signed integer numbers 4)Explain how signed integer numbers are represented in memory using twos complement notation. 5)Convert twos complement numbers into decimal. 6)Convert decimal numbers into twos complement format. 7)Explain the concept of sign extension 8)Convert a binary number into hexadecimal 9)Explain how instructions are represented in memory as machine code

Numeric values can be represented in any base. People commonly use base 10 (decimal). Given a decimal (base 10) number, convert it to binary: 51 ten = ? two -7 ten = ? two CS2710 Computer Organization2

Given a binary number, convert it to decimal format two = ? ten

Processors use each bit of a word to represent a binary digit of a numeric value Consider the integer value 305,419,896 represented with a MIPS 32-bit word: CS2710 Computer Organization4 Bit 0 (LSB) Bit 31 (MSB) In this representation, each bit represents the value x i *2 i, where i is the bit number, and x is either 0 or 1.

Signed numbers: How do we represent negative values (+/-)? First approach – Add a sign bit to the number – 0 indicates positive – 1 indicates negative Example: -11 ten = ? two CS2710 Computer Organization5

Dual zeros: the problem with sign and magnitude == CS2710 Computer Organization6 Sign bit Sign bits were used in early computers, but were soon abandoned. No modern computers use sign bits!

Solution: 2’s complement numbers CS2710 Computer Organization7 Leading 0’s mean positive, leading 1’s mean negative Example for 32 bits: = –1× × … + 1×2 2 +0×2 1 +0×2 0 = –2,147,483, ,147,483,644 = – bits can represent the values –2,147,483,648 to +2,147,483,647 Range: –2 n – 1 to +2 n – 1 – 1

Shortcut: Converting a number into 2’s complement 1.Convert the absolute value of the number into a binary number 2.Complement the bits (1-> 0, 0->1) 3.Add 1 to the value Example: Convert -51 (decimal) to binary using 2’s complement. CS2710 Computer Organization8

Sign extension Representing a number using more bits – Preserve the numeric value Replicate the sign bit to the left – c.f. unsigned values: extend with 0s Examples: 8-bit to 16-bit – +2: => – –2: => CS2710 Computer Organization9

Example Convert -51 to a 16 bit signed binary (base 2) representation based on the 2’s complement value from before CS2710 Computer Organization10

Converting binary to hex (CE1900 review) Hexadecimal – Base 16 – Group binary digits into sets of 4 – Convert each group into a hex digit CS2710 Computer Organization A B C D E F

Example Convert the number to hex Convert the number to hex – What decimal number is this? CS2710 Computer Organization12

Representing Instructions Instructions are represented in binary – Called machine code MIPS instructions (e.g. add $t0, $s1, $s2) – Encoded as 32-bit words – Small number of formats – Regularity in the pattern Register numbers $t0 – $t7 are registers 8 – 15 $t8 – $t9 are registers 24 – 25 $s0 – $s7 are registers 16 – 23 §2.5 Representing Instructions in the Computer

MIPS R[egister]-format Instructions Instruction fields – op: operation code (opcode) – rs: first source register number – rt: second source register number – rd: destination register number – shamt: shift amount (00000 for now) – funct: function code (extends opcode) For add, $t0, $s1, $s2 (see the green card in the textbook) – op = 0 – rs = $s1, register 17 – rt = $s2, register 18 – rd = $t0, register 8 – shamt = 0 – funct = 32 oprsrtrdshamtfunct 6 bits 5 bits

MIPS R-format for the add instruction For add, $t0, $s1, $s2 – op = 0 (for add) – rs = $s1, register 17 – rt = $s2, register 18 – rd = $t0, register 8 – shamt = 0 (for add) – funct = 32 (for add) oprsrtrdshamtfunct 6 bits 5 bits bits 5 bits bits 5 bits Q1: why 5 bits for register values??? Q2: What is the hex equivalent? add instruction syntax: add rd, rs, rt (See the green card in the textbook)

MIPS I[mmediate]-format Instructions Instruction fields – op: operation code (opcode) – rs: first source register number – rt: second source register number – Last field: constant value or 16-bit base address offset For addi, $t0, $s1, 100 # t0 = s – op = 8 – rt = $t0, register 8 – rs = $s1, register 17 – Constant =100 oprsrtConstant or address 6 bits5 bits 16 bits addi instruction syntax: addi rt, rs, value (sign-extended) (See the green card in the textbook) bits5 bits 16 bits

MIPS I[mmediate]-format Instructions Instruction fields – op: operation code (opcode) – rs: first source register number – rt: second source register number – Last field: constant value or 16-bit base address offset For lw $t0, 1200($t1) #load value from memory ref’d by t2 into t1 – op = 35 – rt = $t0, register 8 – rs = $t1, register 9 – Address offset=1200 (bytes) oprsrtConstant or address 6 bits5 bits 16 bits lw instruction syntax: lw rt, (offset)rs, (See the green card in the textbook) bits5 bits 16 bits