Transcription

2 After intro CS After 5 weeks of cs52 What now One last note on CS52 memory address binary representation of code How do we get this instructions (assembly code) 2

3 Encoding assembly instructions Binary numbers revisited What number does 1001 represent in binary opcode rx ry rz Depends! Is it a signed number or If signed, what convention are we using Twos complement Twos complement For a number with n digits the high order bit represents -2 n-1 What number is it signed (twos complement) signed (twos complement)

4 Twos complement Twos complement What number is it What number is it signed (twos complement) signed (twos complement) Twos complement How many numbers can we represent with each approach using 4 bits 16 (2 4 ) numbers, 0000, 0001,., 1111 Doesn t matter the representation! Twos complement How many numbers can we represent with each approach using 32 bits billion numbers signed (twos complement) signed (twos complement)

6 binary representation twos complement binary representation twos complement binary representation twos complement How can you tell if a number is negative binary representation twos complement High order bit! 6

7 A two s complement trick You can also calculate the value of a negative number represented as twos complement as follows:! Flip all of the bits (0 " 1 and 1" 0)! Add 1! The resulting number is the magnitude of the original negative number A two s complement trick You can also calculate the value of a negative number represented as twos complement as follows:! Flip all of the bits (0 " 1 and 1" 0)! Add 1! The resulting number is the magnitude of the original negative number flip the bits add flip the bits add Shifting Shifting 37 >> 2 number to be shifted right shift number of positions to shift 7

8 Shifting Shifting 37 >> 2 37 >> shift right two positions decimal form Shifting Shifting with fixed bit representations In real computers, we generally have a fixed number of bits we use to represent a number (e.g. 8-bits, 16-bits, 32-bits) 37 >> shift right three positions decimal form 8

9 Shifting 8-bit numbers 37 pad with 0s 37 >> 2 What is 37 as an 8-bit binary number Shifting 8-bit numbers >> 2 How do we fill in the leftmost bits shift right two positions Shifting 8-bit numbers 37 >> 2 Shifting 8-bit numbers 37 >> 2 How do we fill in the leftmost bits shift right two positions shift right two positions (discard away bits shifting off) decimal form 9

13 Shifting mathematically What does right shifting by one position do mathematically 0 A B C Shifting mathematically What does right shifting by one position do mathematically 0 A B C 0 0 A B Shifting mathematically What does right shifting by one position do mathematically Shifting mathematically What does right shifting by one position do mathematically 0 A B C = A * B * C * A B C = A * B * C * 2 0 Integer divide by A B = A * B * 2 0 = (A * B * C * 2 0 ) div A B = A * B * 2 0 = (A * B * C * 2 0 ) div 2 13

14 Shifting mathematically What does right shifting by n positions do mathematically Integer division by 2 n (halve n times) >> 1 >> 1 What is as a 4-bit binary number >> 1 How do we fill in the leftmost bit shift right one position 14

15 Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit shift right one position shift right one position Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit >> shift right one position shift right one position decimal form 15

16 Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit >> 1 >> shift right one position decimal form Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit >> 2 Arithmetic shifting mathematically What does right arithmetic shifting by n positions do mathematically for signed numbers Integer division by 2 n (halve n times) Same thing!! shift right two positions decimal form 16

17 Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit shift right one position shift right one position Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit >>> 1 Two types of right shifts: - arithmetic shift: shift in the same as the highorder bit >>> shift right one position decimal form shift right one position decimal form 17

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

4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

CS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm Instructions: Show your work. Correct answers with no work will not receive full credit. Whether

Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,

EE 109 Unit 6 Binary Arithmetic 1 2 Semester Transition Point 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

1 Floating Point The World is Not Just Integers Programming languages support numbers with fraction Called floating-point numbers Examples: 3.14159265 (π) 2.71828 (e) 0.000000001 or 1.0 10 9 (seconds in

CS/COE 0447 Example Problems for Exam 2 Spring 2011 1) Show the steps to multiply the 4-bit numbers 3 and 5 with the fast shift-add multipler. Use the table below. List the multiplicand (M) and product

Signed Binary Numbers Unsigned Binary Numbers We write numbers with as many digits as we need: 0, 99, 65536, 15000, 1979, However, memory locations and CPU registers always hold a constant, fixed number

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

BITWISE OPERATORS There are a number of ways to manipulate binary values. Just as you can with decimal numbers, you can perform standard mathematical operations - addition, subtraction, multiplication,

Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

Integer Representation Representation of integers: unsigned and signed Sign extension Arithmetic and shifting Casting But first, encode deck of cards. cards in suits How do we encode suits, face cards?

Computer Science 52 Logic, Words, and Integers 1 Words and Data The basic unit of information in a computer is the bit; it is simply a quantity that takes one of two values, 0 or 1. A sequence of k bits

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

CS 253 Department of Computer Science College of Engineering Boise State University January 14, 2017 1/30 Motivation Most programming tasks can be implemented using abstractions (e.g. representing data

Arithmetic Operations on Binary Numbers Because of its widespread use, we will concentrate on addition and subtraction for Two's Complement representation. The nice feature with Two's Complement is that

Accuplacer Arithmetic Study Guide I. Terms Numerator: which tells how many parts you have (the number on top) Denominator: which tells how many parts in the whole (the number on the bottom) Example: parts

University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Signed Integers and 2 s Complement Strategy: Use Common Hardware for Two Representations

Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order

Chapter 6 Floating Point Considerations In the early days of computing, floating point arithmetic capability was found only in mainframes and supercomputers. Although many microprocessors designed in the

IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose

UNIT 7A Data Representa1on: Numbers and Text 1 Digital Data 10010101011110101010110101001110 What does this binary sequence represent? It could be: an integer a floa1ng point number text encoded with ASCII

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number

2.2 THE MARIE Instruction Set Architecture MARIE has a very simple, yet powerful, instruction set. The instruction set architecture (ISA) of a machine specifies the instructions that the computer can perform

Declaring Floating Point Data There are three ways to declare floating point storage. These are E D L Single precision floating point, Double precision floating point, and Extended precision floating point.

CS367 Test 1 Review Guide This guide tries to revisit what topics we've covered, and also to briefly suggest/hint at types of questions that might show up on the test. Anything on slides, assigned reading,