Data and Representation, Cheat Sheet of Engineering

Data and representation of computer systems

Typology: Cheat Sheet

2022/2023

Uploaded on 06/14/2023

0g3z1-josh
0g3z1-josh 🇺🇬

1 document

1 / 32

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Representation Computer Organization and Assembly Language
slide 1/33
Outline
Introduction
Numbering Systems
Binary & Hexadecimal Numbers
Base Conversions
Integer Storage Sizes
Binary and Hexadecimal Addition
Binary and Hexadecimal subtraction
Carry and Overflow
Character Storage
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download Data and Representation and more Cheat Sheet Engineering in PDF only on Docsity!

Data Representation Computer Organization and Assembly Language

Outline

 (^) Introduction  (^) Numbering Systems  (^) Binary & Hexadecimal Numbers  (^) Base Conversions  (^) Integer Storage Sizes  (^) Binary and Hexadecimal Addition  (^) Binary and Hexadecimal subtraction  (^) Carry and Overflow  (^) Character Storage

Data Representation Computer Organization and Assembly Language

Introduction

 (^) Computers only deal with binary data (0s and 1s), hence all data manipulated by computers must be represented in binary format.  (^) Machine instructions manipulate many different forms of data:  (^) Numbers:  (^) Integers: 33, +128, -  (^) Real numbers: 1.33, +9.55609, -6.76E12, +4.33E-  (^) Alphanumeric characters (letters, numbers, signs, control characters): examples: A, a, c, 1 ,3, ", +, Ctrl, Shift, etc.  (^) Images (still or moving): Usually represented by numbers representing the Red, Green and Blue (RGB) colors of each pixel in an image,  (^) Sounds: Numbers representing sound amplitudes sampled at a certain rate (usually 20kHz).  (^) So in general we have two major data types that need to be represented in computers; numbers and characters.

Data Representation Computer Organization and Assembly Language

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

Data Representation Computer Organization and Assembly Language

Converting Binary to Decimal

 (^) Weighted positional notation shows how to calculate the decimal value of each binary bit: Decimal = ( d n-

n - )  ( d n-

n - )  ...  ( d 1

1 )  ( d 0

0 ) d = binary digit  (^) binary 10101001 = decimal 169: (1  2 7 ) + (1  2 5 ) + (1  2 3 ) + (1  2 0 ) = 128+32+8+1=

Data Representation Computer Organization and Assembly Language

Another Procedure for Converting from Decimal to

Binary

 (^) Start with a binary representation of all 0’s  (^) Determine the highest possible power of two that is less or equal to the number.  (^) Put a 1 in the bit position corresponding to the highest power of two found above.  (^) Subtract the highest power of two found above from the number.  (^) Repeat the process for the remaining number

Data Representation Computer Organization and Assembly Language

Another Procedure for Converting from Decimal to

Binary

 (^) Example: Converting 76d to Binary  (^) The highest power of 2 less or equal to 76 is 64, hence the seventh (MSB) bit is 1  (^) Subtracting 64 from 76 we get 12.  (^) The highest power of 2 less or equal to 12 is 8, hence the fourth bit position is 1  (^) We subtract 8 from 12 and get 4.  (^) The highest power of 2 less or equal to 4 is 4, hence the third bit position is 1  (^) Subtracting 4 from 4 yield a zero, hence all the left bits are set to 0 to yield the final answer

Data Representation Computer Organization and Assembly Language

Converting Binary to Hexadecimal

 (^) Each hexadecimal digit corresponds to 4 binary bits.  (^) Example: Translate the binary integer 000101101010011110010100 to hexadecimal

Data Representation Computer Organization and Assembly Language

Converting Hexadecimal to Binary

 (^) Each Hexadecimal digit can be replaced by its 4-bit binary number to form the binary equivalent. M1021.swf

Data Representation Computer Organization and Assembly Language

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:

Data Representation Computer Organization and Assembly Language

Integer Storage Sizes

What is the largest unsigned integer that may be stored in 20 bits? Standard sizes:

Data Representation Computer Organization and Assembly Language

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 B 1 1 21 / 16 = 1, remainder 5 Important skill: Programmers frequently add and subtract the addresses of variables and instructions.

Data Representation Computer Organization and Assembly Language

Signed Integers

 (^) Several ways to represent a signed number  (^) Sign-Magnitude  (^) 1's complement  (^) 2's complement  (^) Divide the range of values into 2 equal parts  (^) First part corresponds to the positive numbers (≥ 0)  (^) Second part correspond to the negative numbers (< 0)  (^) Focus will be on the 2's complement representation  (^) Has many advantages over other representations  (^) Used widely in processors to represent signed integers

Data Representation Computer Organization and Assembly Language

Forming the Two's Complement

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. starting value 00100100 = + 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 = -

Data Representation Computer Organization and Assembly Language

Sign Bit

Highest bit indicates the sign. 1 = negative, 0 = positive If highest digit of a hexadecimal is > 7, the value is negative Examples: 8A and C5 are negative bytes A21F and 9D03 are negative words B1C42A00 is a negative double-word