Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Computer Organization and Architecture: Data Representation, Slides of Software Project Management

Digital Logic DesignData Communications and NetworkingComputer OrganizationComputer Architecture

An overview of data representation in computer systems, including binary and hexadecimal numbers, base conversions, integer storage sizes, and signed integers using 2's complement notation. It covers binary and hexadecimal addition and subtraction, as well as carry and overflow concepts.

What you will learn

  • What is 2's complement notation for signed integers?
  • What is hexadecimal number representation?
  • How do you convert hexadecimal to decimal?
  • What is binary number representation?
  • How do you convert binary to decimal?

Typology: Slides

2019/2020

Uploaded on 01/24/2022

nadir99
nadir99 🇬🇧

2 documents

1 / 42

Toggle sidebar

Related documents


Partial preview of the text

Download Computer Organization and Architecture: Data Representation and more Slides Software Project Management in PDF only on Docsity! COMPUTER ORGANIZATION AND ARCHITECTURE HAREEM-E-SAHAR LECTURE NO. 1 FACULTY OF COMPUTING RIPHAH INTERNATIONAL UNIVERSITY (WISH CAMPUS) Introduction to Basic Concepts Course Objectives This course is about familiarizing you with: structure and functions of computer nature and characteristics of modern day computers architectural designs and their compromises Grading Policy There is going to be no extension in any of the deadline, what so ever You can request for re-checking of any of your evaluation as per following rules; Exams: Same day Assignments: 2 days after handing-over Quizzes: 1 day after handing over Warning! After due time, request will not be considered even if it’s genuine. Remember. . . Cheating cases are intolerable. You will be given negative marks for cheated stuff irrespective of the fact that, you were provider or the other one. Your cheating in exam will make it easy for you to step down from the Course with an ‘F’ grade. . .  There will be no re-take of any evaluation if you haven’t informed earlier through a proper channel. Quiz is inevitable so always, expect One  [at least, one in every alternate week] To Survive in Course. . . You have to depend on yourself to have a good grade in the course  You need to appear in demo to have it graded otherwise you will be given 5% of the total marks even if it was best assignment/project of the class  Grading will be individual even for group tasks. So better to shine with your own work in hand otherwise don’t complain  Your written assignments may be marked on the basis of a quiz taken from the assignment. The performance of quiz will be considered as performance in that assignment. Binary Numbers  Each digit (bit) is either 1 or 0  Each bit represents a power of 2: Every binary number is a sum of powers of 2 Converting Binary to Decimal Weighted positional notation shows how to calculate the decimal value of each binary bit: Decimal = (dn-1 2n-1)  (dn-2  2n-2)  ...  (d1  21)  (d0  20) d = binary digit binary 00001001 = decimal 9: (1  23) + (1  20) = 9 Convert Unsigned Decimal to Binary Repeatedly divide the decimal integer by 2. Each remainder is a binary digit in the translated value: 37 = 100101 stop when quotient is zero least significant bit most significant bit Converting Hexadecimal to Decimal Multiply each digit by its corresponding power of 16:  Decimal = (d3  163) + (d2  162) + (d1  161) + (d0  160)  d = hexadecimal digit Examples:  Hex 1234 = (1  163) + (2  162) + (3  161) + (4  160) =  Decimal 4,660  Hex 3BA4 = (3  163) + (11 * 162) + (10  161) + (4  160) =  Decimal 15,268 O ® Lecture 12% Feb, 2018 Converting Decimal to Hexadecimal Decimal 422 = 1A6 hexadecimal stop when quotient is zero least significant digit most significant digit  Repeatedly divide the decimal integer by 16. Each remainder is a hex digit in the translated value:  Is a representation of negative numbers possible?  Unfortunately: › you can not just stick a negative sign in front of a binary number. (it does not work like that)  There are three methods used to represent negative numbers. › Signed magnitude notation › Excess notation › Two’s complement notation 20  Unsigned: - and + are the same.  In signed magnitude  the left-most bit represents the sign of the integer.  0 for positive numbers.  1 for negative numbers.  The remaining bits represent the magnitude of the numbers. 21  Suppose 10011101 is a signed magnitude representation.  The sign bit is 1, then the number represented is negative  The magnitude is 0011101 with a value 24+23+22+20= 29  Then the number represented by 10011101 is –29. position 7 6 5 4 3 2 1 0 Bit pattern 1 0 0 1 1 1 0 1 contribution - 24 23 22 20 22 Two's Complement Representation 8-bit Binary value Unsigned value Signed value 00000000 0 0 00000001 1 +1 00000010 2 +2 . . . . . . . . . 01111110 126 +126 01111111 127 +127 10000000 128 -128 10000001 129 -127 . . . . . . . . . 11111110 254 -2 11111111 255 -1  Positive numbers  Signed value = Unsigned value  Negative numbers  Signed value = Unsigned value – 2n  n = number of bits  Negative weight for MSB  Another way to obtain the signed value is to assign a negative weight to most-significant bit = -128 + 32 + 16 + 4 = -76 1 0 1 1 0 1 0 0 -128 64 32 16 8 4 2 1 Forming the Two's Complement starting value 00100100 = +36 step1: reverse the bits (1's complement) 11011011 step 2: add 1 to the value from step 1 + 1 sum = 2's complement representation 11011100 = -36 Sum of an integer and its 2's complement must be zero: 00100100 + 11011100 = 00000000 (8-bit sum)  Ignore Carry The easiest way to obtain the 2's complement of a binary number is by starting at the LSB, leaving all the 0s unchanged, look for the first occurrence of a 1. Leave this 1 unchanged and complement all the bits after it. Two's Complement of a Hexadecimal To form the two's complement of a hexadecimal  Subtract each hexadecimal digit from 15  Add 1 Examples:  2's complement of 6A3D = 95C2 + 1 = 95C3  2's complement of 92F0 = 6D0F + 1 = 6D10  2's complement of FFFF = 0000 + 1 = 0001 No need to convert hexadecimal to binary Hexadecimal Addition  Divide the sum of two digits by the number base (16). The quotient becomes the carry value, and the remainder is the sum digit. 36 28 28 6A 42 45 58 4B 78 6D 80 B5 11 21 / 16 = 1, remainder 5 Important skill: Programmers frequently add and subtract the addresses of variables and instructions. Hexadecimal Subtraction When a borrow is required from the digit to the left, add 16 (decimal) to the current digit's value Last Carry is ignored C675 A247 242E -1 - 16 + 5 = 21 C675 5DB9 (2's complement) 242E (same result) 1 + 1 Binary Addition Start with the least significant bit (rightmost bit) Add each pair of bits Include the carry in the addition, if present 0 0 0 0 0 1 1 1 0 0 0 0 0 1 0 0 + 0 0 0 0 1 0 1 1 1 (4) (7) (11) carry: 01234bit position: 567 0 1 0 0 0 0 0 0 0 1 0 0 1 1 1 1 + 1 0 0 0 1 1 1 1 79 64 143 (-113) Carry = 0 Overflow = 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 0 1 0 + 0 1 1 1 0 1 1 1 218 (-38) 157 (-99) 119 Carry = 1 Overflow = 1 111 Carry and Overflow Examples  We can have carry without overflow and vice-versa  Four cases are possible (if last 2 carry are not equal => overflow ) 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 + 0 0 0 0 0 1 1 1 15 245 (-8) 7 Carry = 1 Overflow = 0 11111 0 0 0 0 1 0 0 0 0 0 0 0 1 1 1 1 + 0 0 0 1 0 1 1 1 15 8 23 Carry = 0 Overflow = 0 1 Zero & Sign Flag Sign Flag  Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. Zero Flag  Set when result is zero Reading Exercise Read about ASCIIs and Uni-codes from  Appendix A of Data Communications and Networking by Behrouz Fourouzan(4th edition)  Section 1.3.6 Assembly Language for x86 Processors by Kip Irvine Control Characters  The first 32 characters of ASCII table are used for control  Control character codes = 00 to 1F (hex)  Not shown in previous slide  Examples of Control Characters  Character 0 is the NULL character  used to terminate a string  Character 9 is the Horizontal Tab (HT) character  Character 0A (hex) = 10 (decimal) is the Line Feed (LF)  Character 0D (hex) = 13 (decimal) is the Carriage Return (CR)  The LF and CR characters are used together  They advance the cursor to the beginning of next line  One control character appears at end of ASCII table  Character 7F (hex) is the Delete (DEL) character Terminology for Data Representation Binary Integer  Integer stored in memory in its binary format  Ready to be used in binary calculations ASCII Digit String  A string of ASCII digits, such as "123" ASCII binary  String of binary digits: "01010101" ASCII decimal  String of decimal digits: "6517" ASCII hexadecimal  String of hexadecimal digits: "9C7B" Assignment 1 – due next week Presentation on History of computers
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved