COMPUTER ORGANIZATION &
ASSEMBLY LANGUAGE
Data Representation
NUMBER SYSTEM
Any number system using a range of digits that represents a specific
number. The most common numbering systems are decimal, binary,
octal, and hexadecimal.
Numbers are important to computers
represent information precisely
can be processed
For example:
to represent yes or no: use 0 for no and 1 for yes
to represent 4 seasons: 0 (autumn), 1 (winter), 2(spring) and 3 (summer)
2
POSITIONAL NUMBER SYSTEM
A computer can understand positional number system where there are only a few
symbols called digits and these symbols represent different values depending on
the position they occupy in the number.
A value of each digit in a number can be determined using
The digit
The position of the digit in the number
The base of the number system (where base is defined as the total number of
digits available in the number system).
3
DECIMAL NUMBER SYSTEM
4
BINARY NUMBER SYSTEM
5
HEXADECIMAL NUMBER SYSTEM
6
CONVERSION BETWEEN NUMBER SYSTEMS
Converting Hexadecimal to Decimal
Multiply each digit of the hexadecimal number from right to left
with its corresponding power of 16.
Convert the Hexadecimal number 82ADh to decimal number.
7
CONVERSION BETWEEN NUMBER SYSTEMS
Converting Decimal to Hexadecimal
Divide the decimal number by 16.
Take the remainder and record it on the side.
REPEAT UNTIL the decimal number cannot be divided into
anymore.
8
CONVERSION BETWEEN NUMBER SYSTEMS
Converting Binary to Decimal
Multiply each digit of the binary number from right to
left with its corresponding power of 2.
Convert the Binary number 11101 to decimal number.
9
CONVERSION BETWEEN NUMBER SYSTEMS
Converting Decimal to Binary
Divide the decimal number by 2.
Take the remainder and record it on the side.
REPEAT UNTIL the decimal number cannot be divided into
anymore.
10
CONVERSION BETWEEN NUMBER SYSTEMS
Converting Hexadecimal to Binary
Given a hexadecimal number, simply convert each digit to it’s binary
equivalent. Then, combine each 4 bit binary number and that is the
resulting answer.
Converting Binary to Hexadecimal
Begin at the rightmost 4 bits. If there are not 4 bits, pad 0s to the left until
you hit 4. Repeat the steps until all groups have been converted.
11
Binary, Decimal, and Hexadecimal Equivalents.
Binary Decimal Hexadecimal Binary Decimal Hexadecimal
0000 0 0 1000 8 8
0001 1 1 1001 9 9
0010 2 2 1010 10 A
0011 3 3 1011 11 B
0100 4 4 1100 12 C
0101 5 5 1101 13 D
0110 6 6 1110 14 E
0111 7 7 1111 15 F
BINARY ARITHMETIC OPERATIONS
Addition
Like decimal numbers, two numbers can be added by adding each pair
of digits together with carry propagation.
11001 647
+ 10011 + 537
101100 1184
Binary Addition Decimal Addition
13
BINARY ARITHMETIC OPERATIONS
Subtraction
Two numbers can be subtracted by subtracting each pair of digits
together with borrowing, where needed.
11001 627
- 10011 - 537
00110 090
Binary Subtraction Decimal Subtraction
14
HEXADECIMAL ARITHMETIC OPERATIONS
Addition
Like decimal numbers, two numbers can be added by adding
each pair of digits together with carry propagation.
5B39
+ 7AF4
D62D
Hexadecimal Addition
15
16
HEXADECIMAL ARITHMETIC OPERATIONS
Subtraction
Two numbers can be subtracted by subtracting each pair of digits
together with borrowing, where needed.
D26F
- BA94
17DB
Hexadecimal Subtraction
17
MSB AND LSB
In computing, the most significant bit (msb) is the bit position in a binary
number having the greatest value. The msb is sometimes referred to as the
left-most bit.
In computing, the least significant bit (lsb) is the bit position in a binary
integer giving the units value, that is, determining whether the number is
even or odd. The lsb is sometimes referred to as the right-most bit.
18
UNSIGNED INTEGERS
An unsigned integer is an integer at represent a magnitude, so it
is never negative.
Unsigned integers are appropriate for representing quantities
that can be never negative.
19
SIGNED INTEGERS
A signed integer can be positive or negative.
The most significant bit is reserved for the sign:
1 means negative and 0 means positive.
Example:
00001010 = decimal 10
10001010 = decimal -10
20
ONE’S COMPLEMENT
The one’s complement of an integer is obtained by
complementing each bit, that is, replace each 0 by a 1 and each
1 by a 0.
21
2’S COMPLEMENT
Negative integers are stored in computer using 2’s complement.
To get a two’s complement by first finding the one’s
complement, and then by adding 1 to it.
Example
11110011 (one's complement of 12)
+ 00000001 (decimal 1)
11110100 (two's complement of 12)
22
DECIMAL INTERPRETATION
How to interpret the contents of a byte or word as a signed and unsigned
decimal integer?
Unsigned decimal interpretation
Simply just do a binary to decimal conversion
Signed decimal interpretation
If msb is zero, then number is positive and signed decimal is same as
unsigned decimal.
If msb is one then number is negative, so call it -N. To find N, just take the 2’s
complement and then convert to decimal.
23
EXAMPLE
Give unsigned and signed decimal interpretation FE0Ch.
Unsigned decimal interpretation
Signed decimal interpretation
FE0Ch = 1111 1110 0000 1100 (msb is 1, so number is negative).
To find N, get its 2’s complement
0000 0001 1111 0011 (1’s complement of FE0Ch)
+ 1
N = 0000 0001 1111 0100 = 01F4h = 500
So, -N = 500
24
DECIMAL INTERPRETATION
For 16 – bit word, following relationships holds between signed and
unsigned decimal interpretation
From 0000h – 7FFFh signed decimal = unsigned decimal
From 8000h – FFFFh signed decimal = unsigned decimal – 65536.
Example:
Unsigned interpretation of FE0Ch is 65036.
Signed interpretation of FE0Ch = 65036 – 65536 = -500.
25
CHARACTER REPRESENTATION
All data, characters must be coded in binary to be processed by the computer.
ASCII:
American Standard Code for Information Interchange
Most popular character encoding scheme.
Uses 7 bit to code each character.
27 = 128 ASCII codes.
Single character Code = One Byte [7 bits: char code, 8th bit set to zero]
32 to 126 ASCII codes: printable
0 to 31 and 127 ASCII codes: Control characters
26
27
HOW TO CONVERT?
If a byte contains the ASCII code of an uppercase letter, what
hex should be added to it to convert to lower case?
Solution: 20 h
Example: A (41h) a (61 h)
If a byte contains the ASCII code of a decimal digit, What hex
should be subtracted from the byte to convert it to the
numerical form of the characters?
Solution: 30 h
Example: 2 (32 h)
28
CHARACTER STORAGE
ASCII Representation of “123” and 123
'1' '2' '3'
"1 2 3" = 00110001 00110010 00110011
123
123 = 01111011
29
FLOATING POINT REPRESENTATION
In decimal notation we can get around this problem using
scientific notation or floating point notation.
Number Scientific notation Floating-point
notation
1,245,000,000,000 1.245 1012 0.1245 1013
0.0000001245 1.245 10-7 0.1245 10-6
-0.0000001245 -1.245 10-7 -0.1245 10-6
30
FLOATING POINT
-15900000000000000
could be represented as
Mantissa Base
Sign - 159 * 1014 Exponent
- 15.9 * 1015
- 1.59 * 1016
A calculator might display 159 E14
31
FLOATING POINT REPRESENTATION
+
Non-integral binary numbers
0.123 = 1 × 10−1 + 2 × 10−2 + 3 × 10−3
0.1012 = 1 × 2−1 + 0 × 2−2 + 1 × 2−3 = 0.625
110.0112 = 4 + 2 + 0.25 + 0.125 = 6.375
CONVERTING 0.85 TO BINARY
0.85×2 = 1.7
0.7 × 2 = 1.4
0.4 × 2 = 0.8
0.8 × 2 = 1.6
0.6 × 2 = 1.2
0.2 × 2 = 0.4
0.4 × 2 = 0.8
0.8 × 2 = 1.6
Q/A
34