Xuan Guo. Lecture XIV: Review of Chapter 3 & 4. CSC 3210 Computer Organization and Programming Georgia State University. March 5, 2015.

Size: px
Start display at page:

Download "Xuan Guo. Lecture XIV: Review of Chapter 3 & 4. CSC 3210 Computer Organization and Programming Georgia State University. March 5, 2015."

Transcription

1 CSC 3210 Computer Organization and Programming Georgia State University March 5, 2015

2 This lecture Plan for the lecture: Binary Hardware Device Converting from Decimal to other number system Converting from any number system to Decimal Bitwise logical operation Synthetic Instructions Flags Half and Full Adders & Modulus Arithmetic Addition Two s Complement Number Subtraction Shift Unsigned Arithmetic Four condition codes Signed and Unsigned Number Branching Conditions Extended Precision Arithmetic

3 Binary A computer is a bistable device A bistable device: Easy to design and build Has 2 states: 0 and 1 One Binary digit (bit) represents 2 possible states (0, 1)

4 A subscript indicates the number s base E.g. is 100 decimal or binary? We don t know! But = is clear It is difficult for a human to work with long strings of 0 s and 1 s Octal: base 8 Hexadecimal: base 16

5 Binary to Hexadecimal =? in hex Group into 4 bits, from the right: 0101, 0110, 1011, Now translate each (see previous table): => 5, => 6, => b, => 3 So this is 56b3 16 What if there are not enough bits? Pad with 0 s on the left

6 Hexadecimal to Binary f0e5 16 =? in binary Translate each into a group of 4 bits: f 16 => , 0 16 => , e 16 => , 5 16 => So this is

7 Decimal to Any Number Base Take the decimal number, and divide by the new number base Keep track of the quotient and remainder Repeat until quotient = 0 Read number from the bottom to the top

8 Decimal to Binary Binary is base 2 Example: convert 35 (decimal) to binary Quotient Remainder 35 / 2 = / 2 = / 2 = / 2 = / 2 = / 2 = 0 1 So =

9 Any Number Base to Decimal From right to left, multiply the digit of the number-to-convert by its base position Sum all results

10 Binary to Decimal Binary is base 2 Example: convert (binary) to decimal = 1x x x x x2 0 = 1x16 + 0x8 + 1x4 + 1x2 + 0x1 = = 22 So = 22 10

11 In C program and Assembly language Hexadecimal designated by a leading 0x Octal designated by a leading 0 Example mov 0xa, %l0 mov 012, %l1 mov 10, %l2

12 Bitwise Logical Operations There are several binary operations: NOT AND OR XOR NAND NOR

13 SPARC Instruction Format These commands are in the form: command reg rs1, reg_or_imm, reg rd command can be any of the following: and, andn, xor, or, xnor, orn andcc, andncc, xorcc, orcc, xnorcc, orncc the cc means set condition codes andn means a and (not b) orn means a or (not b) not reg rs1, reg rd not reg rd recognized as xnor reg rs1, %g0, reg rd xnor reg rd, %g0, reg rd

14 A Few More Logic Examples (Bonus) In all the examples below, these registers have the following initial values: %l0 = 0x %l1 = 0x9abcdef0 What are the values for %l1 after the instruction? and %l0, %l1, %l1 xor %l0, %l1, %l or %l0, %l1, %l1 9abcdef8 not %l0, %l1 edcba987

15 A Few More Logic Examples (Bonus) %l0 = 0x (0001,0010,0011,0100,0101,0110,0111,1000) 2 %l1 = 0x9abcdef0 (1001,1010,1011,1100,1101,1110,1111,0000) 2 What are the values for %l1 after the instruction? and %l0, %l1, %l1 xor %l0, %l1, %l1 0x = (0001,0010,0011,0100,0101,0110,0111,0000) = (1000,1000,1000,1000,1000,1000,1000,1000) 2 or %l0, %l1, %l1 0x9abcdef8 = (1001,1010,1011,1100,1101,1110,1111,1000) 2 not %l0, %l1 0xedcba987 = (1110,1101,1100,1011,1010,1001,1000,0111) 2

16 Synthetic Instructions The cmp command is a synthetic one. It is a macro that uses %g0. cmp reg rs1, reg_or_imm command will be expanded to: subcc reg rs1, reg_or_imm, %g0 the tst command compares a register to 0: tst reg rs1 which the assembler turns into: orcc reg rs1, %g0, %g0 Since %g0 ignores any updates, only the condition codes are affected.

17 Flags & Testing Flags A word may contain 32 flags. Common flag operations and mnemonics set: bset ( done with or ) clear: bclr ( done with andn ) toggle: btog ( done with xor ) bset/bclr/btog reg_or_imm, reg rd This command will see if one or more flags is set btst reg_or_imm, reg rs1 it expands to: andcc reg rs1, reg_or_imm, %g0 example: test if flag 0x02 is set btst 0x02, %a_r be clear nop set: clear:

18 Binary Sums and Carries a b Sum a b Carry XOR AND

19 Half Adder / Full Adder A half adder For adding 2 bits Gives carry out and sum 1 AND and 1 XOR gate A full adder For adding 2 bits plus a carry in Gives carry out and sum 2 ANDs, 2 XORs, and 1 OR

20 Modulus Arithmetic It considers only numbers in the range 0 <= n <=M, where M is the modulus. SPARC has 32-bit registers, M = 2 32 Each register can store an integer number between 0 and 2 n -1 where n=32 for SPARC if you have a value of 2 n -1 in a register, and you add 1 to this, the register will then hold a value of 0

21 Complement Arithmetic r n -1-b+1 is called the radix complement ten s complement if r=10 two s complement if r=2 r n -1-b is called the diminished radix complement nine s complement if r=10 one s complement if r=2 Any number where the most significant digit >= (r/2) is considered negative means 128 when r=2, n=8 84 means 16 when r=10, n=2

22 Two s Complement In binary, finding the one s complement and the two s complement are easy One s complement: Replace every 0 with a 1, and replace every 1 with a 0 Two s complement: Find the one s complement, and add 1

23 Two s Complement Example What is 16 (decimal) in binary (r=2)? We ll assume n=8 16 = in binary one s complement add two s complement

24 Addition and Subtraction The two s complement system is an interpretation of numbers in registers; the hardware always performs binary addition. To subtract, find the 2 s complement of the 2 nd operand, and add There is no need for a hardware subtractor

25 Shift Instructions A registers contents can be shifted left shift is like multiplying by 2 right shift is like dividing by 2 Shift right logical (srl) 0 Shift right arithmetic (sra) Shift left logical (sll) 0 Shift left arithmetic is not provided, it would be the same as shift left logical

26 Shift Instructions Shift right logical (srl) srl reg rs1, reg_or_imm, reg rd Shift right arithmetic (sra) sra reg rs1, reg_or_imm, reg rd Shift left logical (sll) sll reg rs1, reg_or_imm, reg rd The number of shifts is the low 5 bits of the reg_or_imm, so largest shift is 31

27 Branching Conditions Branching is based on the following flags: N (negative) the most significant bit of the result not used with unsigned numbers V (overflow) when result is too big for the register Z (zero) set when all bits of the result are 0 C (carry) set when an addition has carry out, or when subtraction does not have carry out

28 Signed Branches Assembler Signed Arithmetic Mnemonic Branches Condition Codes bl branch on less (N xor V) = 1 ble branch on less or equal Z or (N xor V) = 1 be branch on equal Z = 1 bne branch on not equal Z = 0 bge branch on greater or equal (N xor V) = 0 bg branch on greater Z or (N xor V) = 0

29 Unsigned Branches The carry flag (C) can be used instead of the overflow flag (V) Assembler Unsigned Arithmetic Mnemonic Branches Condition Codes blu branch on less C = 1 bleu branch on less or equal Z or C = 1 be branch on equal Z = 1 (same as signed branch) bne branch on not equal Z = 0 (same as signed branch) bgeu branch on greater or equal C = 0 bgu branch on greater Z = 0 and C = 0

30 Condition Code Branches Assembler Condition Code Mnemonic Branches Condition Codes bneg branch on negative N = 1 bpos branch on positive N = 0 bz branch on zero set Z = 1 (same as be) bnz branch on zero not set Z = 0 (same as bne) bvs branch on overflow set V = 0 bvc branch on overflow clear V = 1 bcs branch on carry set C = 1 (same as blu) bcc branch on carry clear C = 0 (same as bgeu)

31 Numeric Labels The assembler allows single-digit labels to appear many times in a single source file. [page 137] 1: addcc %lo_r, %lo_r, %lo_r bcc 1f! find label 1 forward add %hi_r, %hi_r, %hi_r bset 1, %hi_r The letter b or f must be appended to the digit, for backward or forward direction. The closest label in that direction will be the branch target, if the branch is taken. These are good for labels used in control structures.

32 Extended Precision What if we need to work with data that are more than 32 bits wide? We can use extended precision instructions, with the carry addx reg rs1, reg_or_imm, reg rd addxcc reg rs1, reg_or_imm, reg rd these mean: reg rd = reg rs1 + reg_or_imm + C

33 Extended Precision (Sub) We can use extended precision instructions, with the carry subx reg rs1, reg_or_imm, reg rd subxcc reg rs1, reg_or_imm, reg rd these mean: reg rd = reg rs1 - reg_or_imm - C Data larger than 32 bits must be stored in 2 (or more) registers. That is, add (or sub) the low part first, then use the extended precision addx (or subx) for the high part. This is just like doing arithmetic on paper, where we work with one digit at a time.

34 Extended Precision example Given a number A spans over registers %l1 to %l2 and a number B spans over registers %o1 to %o2. Write an assembly code segment to perform A = A - B [A = %l1%l2, B = %o1%o2] ABCDEFABCDEFABCD - BCDEFBCDEFBCDEFB = EEEEF3DDDE32CCD2 subcc %l2, %o2, %l2! sub bits 0 to 31 subx %l1, %o1, %l1! sub bits 32 to 63 and C

Chapter 4 Simple Calculations

Chapter 4 Simple Calculations Chapter 4 Simple Calculations Arthur B. Maccabe Department of Computer Science The University of New Mexico Copyright 1993 2000, Arthur B. Maccabe and McGraw-Hill, Inc. Overview Preliminaries RISC/CISC

More information

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26) Lecture Topics Today: Integer Arithmetic (P&H 3.1-3.4) Next: continued 1 Announcements Consulting hours Introduction to Sim Milestone #1 (due 1/26) 2 1 Overview: Integer Operations Internal representation

More information

Lecture VIII: Branching and Control Statements. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University.

Lecture VIII: Branching and Control Statements. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. Lecture VIII: Branching and Control Statements CSC 3210 Computer Organization and Programming Georgia State University February 5, 2015 This lecture Plan for the lecture: Recap: Filling delay slot Branching

More information

Compiler Design. Homework 1. Due Date: Thursday, January 19, 2006, 2:00

Compiler Design. Homework 1. Due Date: Thursday, January 19, 2006, 2:00 Homework 1 Due Date: Thursday, January 19, 2006, 2:00 Your Name: Question 1 Is SPARC big- or little- Endian? When a word of data is stored in memory, which byte is stored in the first byte (i.e., in the

More information

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: The MIPS ISA (P&H ) Consulting hours. Milestone #1 (due 1/26)

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: The MIPS ISA (P&H ) Consulting hours. Milestone #1 (due 1/26) Lecture Topics Today: Integer Arithmetic (P&H 3.1-3.4) Next: The MIPS ISA (P&H 2.1-2.14) 1 Announcements Consulting hours Milestone #1 (due 1/26) Milestone #2 (due 2/2) 2 1 Review: Integer Operations Internal

More information

Number System. Introduction. Decimal Numbers

Number System. Introduction. Decimal Numbers Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

More information

Lecture VII: The debugger gdb and Branching. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University.

Lecture VII: The debugger gdb and Branching. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. Lecture VII: The debugger gdb and Branching CSC 3210 Computer Organization and Programming Georgia State University February 3, 2015 This lecture Plan for the lecture: Recap: Pipelining Filling delay slot

More information

Unsigned Binary Integers

Unsigned Binary Integers Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0

More information

Unsigned Binary Integers

Unsigned Binary Integers Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0

More information

2.2: Bitwise Logical Operations

2.2: Bitwise Logical Operations 2.2: Bitwise Logical Operations Topics: Introduction: logical operations in C/C++ logical operations in MIPS In 256 lecture, we looked at bitwise operations in C/C++ and MIPS. We ll look at some simple

More information

Basic Arithmetic (adding and subtracting)

Basic Arithmetic (adding and subtracting) Basic Arithmetic (adding and subtracting) Digital logic to show add/subtract Boolean algebra abstraction of physical, analog circuit behavior 1 0 CPU components ALU logic circuits logic gates transistors

More information

Chapter 2 SPARC Architecture Chinua Umoja

Chapter 2 SPARC Architecture Chinua Umoja Chapter 2 SPARC Architecture Chinua Umoja 1 SPARC is a load/store architecture Registers used for all arithmetic and logical operations 32 registers available at a time Uses only load and store instructions

More information

CS & IT Conversions. Magnitude 10,000 1,

CS & IT Conversions. Magnitude 10,000 1, CS & IT Conversions There are several number systems that you will use when working with computers. These include decimal, binary, octal, and hexadecimal. Knowing how to convert between these number systems

More information

10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e 10-1 C D E A B 10-2 A B A B C (A B) C D A A B (A B) C E D (A B) C D E (A B) C + D E (A B) C 10-3 Opcode Mode Address or operand 10-4 Memory 250 Opcode Mode PC = 250 251 ADRS 252 Next instruction ACC Opcode:

More information

Advanced Computer Architecture-CS501

Advanced Computer Architecture-CS501 Advanced Computer Architecture Lecture No. 34 Reading Material Vincent P. Heuring & Harry F. Jordan Chapter 6 Computer Systems Design and Architecture 6.1, 6.2 Summary Introduction to ALSU Radix Conversion

More information

Octal and Hexadecimal Integers

Octal and Hexadecimal Integers Octal and Hexadecimal Integers CS 350: Computer Organization & Assembler Language Programming A. Why? Octal and hexadecimal numbers are useful for abbreviating long bitstrings. Some operations on octal

More information

CMPE223/CMSE222 Digital Logic Design. Positional representation

CMPE223/CMSE222 Digital Logic Design. Positional representation CMPE223/CMSE222 Digital Logic Design Number Representation and Arithmetic Circuits: Number Representation and Unsigned Addition Positional representation First consider integers Begin with positive only

More information

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Arithmetic and Logical Operations

Arithmetic and Logical Operations Arithmetic and Logical Operations 2 CMPE2c x +y + sum Or in tabular form Binary Addition Carry Out Sum B A Carry In Binary Addition And as a full adder a b co ci sum 4-bit Ripple-Carry adder: Carry values

More information

Chapter 3: part 3 Binary Subtraction

Chapter 3: part 3 Binary Subtraction Chapter 3: part 3 Binary Subtraction Iterative combinational circuits Binary adders Half and full adders Ripple carry and carry lookahead adders Binary subtraction Binary adder-subtractors Signed binary

More information

The Assembly Language of the Boz 5

The Assembly Language of the Boz 5 The Assembly Language of the Boz 5 The Boz 5 uses bits 31 27 of the IR as a five bit opcode. Of the possible 32 opcodes, only 26 are implemented. Op-Code Mnemonic Description 00000 HLT Halt the Computer

More information

Number representations

Number representations Number representations Number bases Three number bases are of interest: Binary, Octal and Hexadecimal. We look briefly at conversions among them and between each of them and decimal. Binary Base-two, or

More information

H8/300L Series Programming Manual

H8/300L Series Programming Manual H8/300L Series Programming Manual Notice When using this document, keep the following in mind: 1. This document may, wholly or partially, be subject to change without notice. 2. All rights are reserved:

More information

Course Topics - Outline

Course Topics - Outline Course Topics - Outline Lecture 1 - Introduction Lecture 2 - Lexical conventions Lecture 3 - Data types Lecture 4 - Operators Lecture 5 - Behavioral modeling A Lecture 6 Behavioral modeling B Lecture 7

More information

RISC-V Assembly and Binary Notation

RISC-V Assembly and Binary Notation RISC-V Assembly and Binary Notation L02-1 Course Mechanics Reminders Course website: http://6004.mit.edu All lectures, videos, tutorials, and exam material can be found under Information/Resources tab.

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications EE 37 Microcontroller Applications Lecture 8: Instruction Subset & Machine Language: A Brief Tour of the 68HC Instruction Set - Miller 2.4 & 5.2-5.3 & Appendix A Based on slides for ECE37 by Profs. Davis,

More information

Chapter 4 Arithmetic Functions

Chapter 4 Arithmetic Functions Logic and Computer Design Fundamentals Chapter 4 Arithmetic Functions Charles Kime & Thomas Kaminski 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Overview Iterative combinational

More information

TABLE 9-1. Symbolic Convention for Addressing Modes. Register indirect LDA (R1) ACC M[ R1] Refers to Figure 9-4. Addressing mode. Symbolic convention

TABLE 9-1. Symbolic Convention for Addressing Modes. Register indirect LDA (R1) ACC M[ R1] Refers to Figure 9-4. Addressing mode. Symbolic convention T-236 Symbolic Convention for Addressing Modes TABLE 9-1 Symbolic Convention for Addressing Modes Refers to Figure 9-4 Addressing mode Symbolic convention Register transfer Effective address Contents of

More information

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

CSC201, SECTION 002, Fall 2000: Homework Assignment #2 1 of 7 11/8/2003 7:34 PM CSC201, SECTION 002, Fall 2000: Homework Assignment #2 DUE DATE Monday, October 2, at the start of class. INSTRUCTIONS FOR PREPARATION Neat, in order, answers easy to find. Staple

More information

Tailoring the 32-Bit ALU to MIPS

Tailoring the 32-Bit ALU to MIPS Tailoring the 32-Bit ALU to MIPS MIPS ALU extensions Overflow detection: Carry into MSB XOR Carry out of MSB Branch instructions Shift instructions Slt instruction Immediate instructions ALU performance

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two

More information

ECE 30 Introduction to Computer Engineering

ECE 30 Introduction to Computer Engineering ECE 30 Introduction to Computer Engineering Study Problems, Set #6 Spring 2015 1. With x = 1111 1111 1111 1111 1011 0011 0101 0011 2 and y = 0000 0000 0000 0000 0000 0010 1101 0111 2 representing two s

More information

GR712RC Incorrect Annulation of Floating-point Operation on Instruction Cache Parity Error. Technical note Doc. No GRLIB-TN-0012 Issue 1.

GR712RC Incorrect Annulation of Floating-point Operation on Instruction Cache Parity Error. Technical note Doc. No GRLIB-TN-0012 Issue 1. Template: GQMS-TPLT-1-1-0 GR712RC Incorrect Annulation of Floating-point Operation on Instruction Cache Parity Error Technical note 2017-12-21 Doc. No Issue 1.3 Date: 2017-12-21 Page: 2 of 9 CHANGE RECORD

More information

Sheet For the following C code: a = b + c; b = a + c; d = a b; Write an equivalent assembly MIPS program. Solution:

Sheet For the following C code: a = b + c; b = a + c; d = a b; Write an equivalent assembly MIPS program. Solution: Sheet 2 1- For the following C code: a = b + c; b = a + c; d = a b; Write an equivalent assembly MIPS program. add a, b, c add b, a, c sub d, a, b # b + c a # a + c b # a - b d 2- What is the corresponding

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 4: Logic Operations and Introduction to Conditionals Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Previously examined

More information

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

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture EEM 486: Computer Architecture Lecture 2 MIPS Instruction Set Architecture EEM 486 Overview Instruction Representation Big idea: stored program consequences of stored program Instructions as numbers Instruction

More information

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation Complement Number Systems A complement number system is used to represent positive and negative integers A complement number system is based on a fixed length representation of numbers Pretend that integers

More information

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture Points ddressed in this Lecture Lecture 6: Signed Numbers rithmetic Circuits Professor Peter Cheung Department of EEE, Imperial College London (Floyd 2.5-2.7, 6.1-6.7) (Tocci 6.1-6.11, 9.1-9.2, 9.4) Representing

More information

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Ziad Matni Dept. of Computer Science, UCSB Adding this Class The class is full I will not be adding more ppl L Even if others

More information

6. Binary and Hexadecimal

6. Binary and Hexadecimal COMP1917 15s2 6. Binary and Hexadecimal 1 COMP1917: Computing 1 6. Binary and Hexadecimal Reading: Moffat, Section 13.2 Outline Number Systems Binary Computation Converting between Binary and Decimal Octal

More information

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other Kinds Of Data CHAPTER 3 DATA REPRESENTATION Numbers Integers Unsigned Signed Reals Fixed-Point Floating-Point Binary-Coded Decimal Text ASCII Characters Strings Other Graphics Images Video Audio Numbers

More information

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions Outline EEL-4713 Computer Architecture Multipliers and shifters Multiplication and shift registers Chapter 3, section 3.4 Next lecture Division, floating-point 3.5 3.6 EEL-4713 Ann Gordon-Ross.1 EEL-4713

More information

ENE 334 Microprocessors

ENE 334 Microprocessors Page 1 ENE 334 Microprocessors Lecture 10: MCS-51: Logical and Arithmetic : Dejwoot KHAWPARISUTH http://webstaff.kmutt.ac.th/~dejwoot.kha/ ENE 334 MCS-51 Logical & Arithmetic Page 2 Logical: Objectives

More information

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 CS 64 Lecture 2 Data Representation Reading: FLD 1.2-1.4 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) 1010 10?= 1010 2?= 1

More information

ARM Assembly Language. Programming

ARM Assembly Language. Programming Outline: ARM Assembly Language the ARM instruction set writing simple programs examples Programming hands-on: writing simple ARM assembly programs 2005 PEVE IT Unit ARM System Design ARM assembly language

More information

Basic Processor Design

Basic Processor Design Basic Processor Design Design Instruction Set Design Datapath Design Control Unit This lecture deals with Instruction Set Design. 1001 Instruction Set Terminology Mnemonic (Instruction Name) SUBI Syntax

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize

More information

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1 Instructions: MIPS ISA Chapter 2 Instructions: Language of the Computer 1 PH Chapter 2 Pt A Instructions: MIPS ISA Based on Text: Patterson Henessey Publisher: Morgan Kaufmann Edited by Y.K. Malaiya for

More information

Lecture 2: Number Systems

Lecture 2: Number Systems Lecture 2: Number Systems Syed M. Mahmud, Ph.D ECE Department Wayne State University Original Source: Prof. Russell Tessier of University of Massachusetts Aby George of Wayne State University Contents

More information

COMP 303 Computer Architecture Lecture 6

COMP 303 Computer Architecture Lecture 6 COMP 303 Computer Architecture Lecture 6 MULTIPLY (unsigned) Paper and pencil example (unsigned): Multiplicand 1000 = 8 Multiplier x 1001 = 9 1000 0000 0000 1000 Product 01001000 = 72 n bits x n bits =

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering MIPS Instruction Set James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy MIPS Registers MIPS

More information

CSE 30 Winter 2009 Final Exam

CSE 30 Winter 2009 Final Exam Login: cs30x Student ID Name Signature CSE 30 Winter 2009 Final Exam 1. Number Systems / C Compiling Sequence (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection (12 points) 3. Branching

More information

Arithmetic Processing

Arithmetic Processing CS/EE 5830/6830 VLSI ARCHITECTURE Chapter 1 Basic Number Representations and Arithmetic Algorithms Arithmetic Processing AP = (operands, operation, results, conditions, singularities) Operands are: Set

More information

68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1

68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1 68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1 Lecture Overview The 68000 Instruction Set continued The understand and effectively use an architecture must understand the register

More information

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence GATE Postal Correspondence Computer Sc. & IT 1 Digital Logic Computer Sciencee & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts,

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications Lecture Overview EE 3170 Microcontroller Applications Lecture 7 : Instruction Subset & Machine Language: Conditions & Branches in Motorola 68HC11 - Miller 2.2 & 2.3 & 2.4 Based on slides for ECE3170 by

More information

ECEN 468 Advanced Logic Design

ECEN 468 Advanced Logic Design ECEN 468 Advanced Logic Design Lecture 26: Verilog Operators ECEN 468 Lecture 26 Operators Operator Number of Operands Result Arithmetic 2 Binary word Bitwise 2 Binary word Reduction 1 Bit Logical 2 Boolean

More information

CSE 30 Fall 2006 Final Exam

CSE 30 Fall 2006 Final Exam cs30x_ Student ID Name _ Signature CSE 30 Fall 2006 Final Exam 1. Number Systems _ (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection _ (12 points) 3. Branching _ (20 points) 4. Bit

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering MIPS Instruction Set James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy MIPS Registers MIPS

More information

Integer Multiplication and Division

Integer Multiplication and Division Integer Multiplication and Division COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

MACHINE LEVEL REPRESENTATION OF DATA

MACHINE LEVEL REPRESENTATION OF DATA MACHINE LEVEL REPRESENTATION OF DATA CHAPTER 2 1 Objectives Understand how integers and fractional numbers are represented in binary Explore the relationship between decimal number system and number systems

More information

Reconfigurable Computing Systems ( L) Fall 2012 Tiny Register Machine (TRM)

Reconfigurable Computing Systems ( L) Fall 2012 Tiny Register Machine (TRM) Reconfigurable Computing Systems (252-2210-00L) Fall 2012 Tiny Register Machine (TRM) L. Liu Department of Computer Science, ETH Zürich Fall semester, 2012 1 Introduction Jumping up a few levels of abstraction.

More information

Exam 1 Fun Times. EE319K Fall 2012 Exam 1A Modified Page 1. Date: October 5, Printed Name:

Exam 1 Fun Times. EE319K Fall 2012 Exam 1A Modified Page 1. Date: October 5, Printed Name: EE319K Fall 2012 Exam 1A Modified Page 1 Exam 1 Fun Times Date: October 5, 2012 Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will

More information

TSK3000A - Generic Instructions

TSK3000A - Generic Instructions TSK3000A - Generic Instructions Frozen Content Modified by Admin on Sep 13, 2017 Using the core set of assembly language instructions for the TSK3000A as building blocks, a number of generic instructions

More information

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems Decimal & Binary Representation Systems Decimal & binary are positional representation systems each position has a value: d*base i for example: 321 10 = 3*10 2 + 2*10 1 + 1*10 0 for example: 101000001

More information

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-1 CHAPTER V CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-2 NUMBER SYSTEMS RADIX-R REPRESENTATION Decimal number expansion 73625 10 = ( 7 10 4 ) + ( 3 10 3 ) + ( 6 10 2 ) + ( 2 10 1 ) +(

More information

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018 Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB Administrative Stuff The class is full I will not be adding more ppl

More information

RCX internals (Revised February 24)

RCX internals (Revised February 24) CMSC 23000 Winter 2006 Operating Systems Handout 3 January 27 RCX internals (Revised February 24) 1 Introduction This document collects together various pieces of information about the hardware in the

More information

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

More information

MACHINE LANGUAGE AND ASSEMBLY LANGUAGE

MACHINE LANGUAGE AND ASSEMBLY LANGUAGE CHAPTER 4 MACHINE LANGUAGE AND ASSEMBLY LANGUAGE 103 4 MACHINE LANGUAGE AND ASSEMBLY LANGUAGE 4.1 Introduction In this chapter we explore the inner workings of a computer system. The central processing

More information

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects: Numeral Systems -Numeral System -Positional systems -Decimal -Binary -Octal Subjects: Introduction A numeral system (or system of numeration) is a writing system for expressing numbers, that is a mathematical

More information

Arithmetic for Computers

Arithmetic for Computers MIPS Arithmetic Instructions Cptr280 Dr Curtis Nelson Arithmetic for Computers Operations on integers Addition and subtraction; Multiplication and division; Dealing with overflow; Signed vs. unsigned numbers.

More information

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Number Systems Readings: 3-3.3.3, 3.3.5 Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches Missing: Way to implement

More information

Review 1/2 MIPS assembly language instructions mapped to numbers in 3 formats. CS61C Negative Numbers and Logical Operations R I J.

Review 1/2 MIPS assembly language instructions mapped to numbers in 3 formats. CS61C Negative Numbers and Logical Operations R I J. CS61C Negative Numbers and Logical Operations cs 61C L7 Number.1 Lecture 7 February 10, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html Review 1/2

More information

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls Instructors: Dr. Phillip Jones 1 Announcements Final Projects Projects: Mandatory

More information

Chapter 1 Preliminaries

Chapter 1 Preliminaries Chapter 1 Preliminaries This chapter discusses the major classes of programming languages and the relationship among them. It also discusses the binary and the hexadecimal number systems which are used

More information

Beginning C Programming for Engineers

Beginning C Programming for Engineers Beginning Programming for Engineers R. Lindsay Todd Lecture 6: Bit Operations R. Lindsay Todd () Beginning Programming for Engineers Beg 6 1 / 32 Outline Outline 1 Place Value Octal Hexadecimal Binary

More information

CSE 30 Spring 2007 Final Exam

CSE 30 Spring 2007 Final Exam Login: cs30x Student ID Name Signature CSE 30 Spring 2007 Final Exam 1. Number Systems (25 points) 2. Binary Addition/Condition Code Bits/Overflow Detection (12 points) 3. Branching (19 points) 4. Bit

More information

EE292: Fundamentals of ECE

EE292: Fundamentals of ECE EE292: Fundamentals of ECE Fall 2012 TTh 10:00-11:15 SEB 1242 Lecture 22 121115 http://www.ee.unlv.edu/~b1morris/ee292/ 2 Outline Review Binary Number Representation Binary Arithmetic Combinatorial Logic

More information

BINARY SYSTEM. Binary system is used in digital systems because it is:

BINARY SYSTEM. Binary system is used in digital systems because it is: CHAPTER 2 CHAPTER CONTENTS 2.1 Binary System 2.2 Binary Arithmetic Operation 2.3 Signed & Unsigned Numbers 2.4 Arithmetic Operations of Signed Numbers 2.5 Hexadecimal Number System 2.6 Octal Number System

More information

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

10.1. Unit 10. Signed Representation Systems Binary Arithmetic 0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system

More information

CS101 Lecture 04: Binary Arithmetic

CS101 Lecture 04: Binary Arithmetic CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University How do we represent data in a computer?!

More information

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude Chapter 2 Positional number systems A positional number system represents numeric values as sequences of one or more digits. Each digit in the representation is weighted according to its position in the

More information

CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

More information

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures Homework 3 Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) 1 CSCI 402: Computer Architectures Arithmetic for Computers (2) Fengguang Song Department

More information

Harry H. Porter, 2006

Harry H. Porter, 2006 The SPARC Computer Architecture Harry Porter Portland State University 1 CS-321 Lexer Parser Type Checking Intermediate Code Generation All semantic error checking finished in this phase IR - Intermediate

More information

CHW 261: Logic Design

CHW 261: Logic Design CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER

More information

srl - shift right logical - 0 enters from left, bit drops off right end note: little-endian bit notation msb lsb "b" for bit

srl - shift right logical - 0 enters from left, bit drops off right end note: little-endian bit notation msb lsb b for bit Clemson University -- CPSC 231 Shifts (p. 123) srl - shift right logical - 0 enters from left, bit drops off right end 0 b 31 b 30 b 2 b 1 b 0 note: little-endian bit notation msb lsb "b" for bit a f 5

More information

Chapter 1 Review of Number Systems

Chapter 1 Review of Number Systems 1.1 Introduction Chapter 1 Review of Number Systems Before the inception of digital computers, the only number system that was in common use is the decimal number system which has a total of 10 digits

More information

ECE 372 Microcontroller Design Assembly Programming Arrays. ECE 372 Microcontroller Design Assembly Programming Arrays

ECE 372 Microcontroller Design Assembly Programming Arrays. ECE 372 Microcontroller Design Assembly Programming Arrays Assembly Programming Arrays Assembly Programming Arrays Array For Loop Example: unsigned short a[]; for(j=; j

More information

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR UNIT I Digital Systems: Binary Numbers, Octal, Hexa Decimal and other base numbers, Number base conversions, complements, signed binary numbers, Floating point number representation, binary codes, error

More information

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference. 1) [ 9 marks] Write a sequence of directives for an HCS12 assembly language program that performs all of these tasks, in this order: a) Define an array called Measurements starting from memory location

More information

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC 1 2 Semester Transition Point EE 109 Unit 11 Binary Arithmetic At this point we are going to start to transition in our class to look more at the hardware organization and the low-level software that is

More information

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring EE 260: Introduction to Digital Design Arithmetic II Yao Zheng Department of Electrical Engineering University of Hawaiʻi at Mānoa Overview n Integer multiplication n Booth s algorithm n Integer division

More information

MIPS Integer ALU Requirements

MIPS Integer ALU Requirements MIPS Integer ALU Requirements Add, AddU, Sub, SubU, AddI, AddIU: 2 s complement adder/sub with overflow detection. And, Or, Andi, Ori, Xor, Xori, Nor: Logical AND, logical OR, XOR, nor. SLTI, SLTIU (set

More information

Condition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Condition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff Condition Code Register 1 Topics Condition code register Addition and subtraction instructions Conditional branches 2 Condition Code Register Condition code bits are automatically set by some instructions

More information

Number Systems CHAPTER Positional Number Systems

Number Systems CHAPTER Positional Number Systems CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

More information

Number Systems and Their Representations

Number Systems and Their Representations Number Representations Cptr280 Dr Curtis Nelson Number Systems and Their Representations In this presentation you will learn about: Representation of numbers in computers; Signed vs. unsigned numbers;

More information

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014 Problem 1 (4 parts, 21 points) Encoders and Pass Gates Part A (8 points) Suppose the circuit below has the following input priority: I 1 > I 3 > I 0 > I 2. Complete the truth table by filling in the input

More information