MCA-103
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
UNIT -1: 1. Representation of Information:
2. Basics Building Blocks:
UNIT -2: 3. CPU Organization:
UNIT -3: 4. Assembly Language Programming:
Suggested Readings:
1. M. Morris Mano : Computer System Architecture, 3rd Ed. Prentice Hall of India.
2. Stalling William : Computer Organization & Architecture.
3. M. Morris Mano : Digital Logic and Computer Design Prentice Hall of India.
4. M. Morris Mano : Digital Design 2nd Ed. Prentice Hall of India.
Mr. Harish Kumar
Lecturer(MCA) GITM, Gurgaon
UNIT -1: 1. Representation of Information:
Topics: 1. Number System, Integer and floating point representation
2. Character Codes (ASCII, EBCDIC)
3. Error Detection and correction codes.
1. Number System:
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
UNIT -1: 1. Representation of Information:
2. Basics Building Blocks:
UNIT -2: 3. CPU Organization:
UNIT -3: 4. Assembly Language Programming:
Suggested Readings:
1. M. Morris Mano : Computer System Architecture, 3rd Ed. Prentice Hall of India.
2. Stalling William : Computer Organization & Architecture.
3. M. Morris Mano : Digital Logic and Computer Design Prentice Hall of India.
4. M. Morris Mano : Digital Design 2nd Ed. Prentice Hall of India.
Mr. Harish Kumar
Lecturer(MCA) GITM, Gurgaon
UNIT -1: 1. Representation of Information:
Topics: 1. Number System, Integer and floating point representation
2. Character Codes (ASCII, EBCDIC)
3. Error Detection and correction codes.
1. Number System:
A computer understands information composed of only zeros and ones Therefore instructions and data are processed by the computer in the form of 0’s and 1’s. We are familiar with the decimal number system in which digits are 0,1,2,3,4,5,6,7,8,9. The most widely used number system is the positional system. In this system position of a digit indicates the significance to be attached to that digit. Positional Number systems have a radix or a base.
The most widely used number system is the positional system. In this system position of a digit indicates the significance to be attached to that digit. Positional Number systems have a radix or a base.
Positional Number systems are:-
Decimal Number
Binary Number
Octal Number
Hexadecimal Number
The non-positional number system with which all of us are familiar is the Roman number systems. This number system is difficult to use as it has no symbol for zero. The Idea of positional value number system was the greatest invention of this age and this came from India. In the words of Marquis De Laplace, the great mathematician.
Decimal Numbers:
In the decimal number system there are ten digits which are used to form decimal Numbers. Ten unique symbols 0, 1, 2,3,4,5,6,7,8 and 9 are used to represent ten
Decimal digits. Human beings have always used them in counting. So the decimal Number system followed naturally from the use of our fingers, the base or radix of a number system is defined as the number of digits it uses to represent numbers in the systems. Since the decimal number system uses ten digits, from 0 to 9, its base or radix is 10. The decimal number system is also called base-10 number system.
The string of digits 724.5 is interpreted to represent the quantity
7 X 102 + 2 X 101 + 4 X 100 + 5 X 10-1
That is 7 hundreds, plus 2 tens, plus 4 units, plus 5 tenths.
In general, a number with a decimal point is represented by a series of coefficients as follows:
a5 a4 a3 a2 a1 a0. a-1 a-2 a-3
The power of 10 by which the coefficient must be multiplied
105a5 + 104 a4 +103 a3 + 102 a2 + 101 a1 + 100 a0 + 10-1 a-1 + 10-2 a-2 +10-3 a-3
Binary Numbers(or Base 2 system):
The binary number system uses only two digits, 0 and 1 In short a binary digit is called a bit. The storing or computing electronic elements of a computer have only two stable states. The output of such electronic circuit at any time is either HIGH or LOW. These states can be represent by 1 and 0 respectively, that is HIGH is represented by 1 and LOW by 0.Due to this characteristics of electronic circuits, a computer can understand information composed of only 0s and 1s. So all computers perform their internal manipulations on binary digits. But the programmers use data and other information in the form of decimal digits, alphabets and special symbols.
The decimal equivalent of the binary number 11010.11 is 26.75 as follows-
=1 X 24 + 1 X 23 + 0 X 22 + 1 X 21 + 0 X 20 + 1 X 2-1 + 1 X 2-2
= 16 + 8 + 0 + 2 + 0 + ½ + ¼
=26.75
In general, a number expressed in base-r system has coefficients multiplied by power of r:
an.. rn + a n-1 . r n-1 + ………..+ a2. r2 + a1. r + a0
Example of Addition, Subtraction and multiplication of two binary numbers are shown below:
Addition: carry 1111
augend: 101101
addend : + 100111
____________
sum: 1010100
Subtraction: carrcy 2 2
minuend: 101101
subtrahend: - 100111
____________
difference 000110
Multiplication:
Multicland: 1011
Multiplier: X 101
_______
1011
0000
1011
___________
110111
Octal Number System:
In the octal number system, the base is 8. Hence, there are only eight symbols or digits: 0,1,2,3,4,5,6 and 7. The largest single digit is 7 (one less than the base)
Each position in an octal number represents a power of the base (8). Therefore equivalent of the octal number 2057 written as 20578 is:
=(2 X 83) + (0 X 82 ) + (5 X 81) + (7 X 80)
= 2 X 512 + 0 + 40 + 7
= 1024 + 47
= 107110
· Since octal base is 8 so in binary form 8 = 23 so conversion of binary to octal group of 3 digits each starting from the binary point and proceeding to the left and to the right.
For example: 10110001101011
10 110 001 101 011
2 6 1 5 3
= (26153)8
Hexadecimal Number System:
In the Hexadecimal number system, the base is 16. Hence, there are sixteen symbols or digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F. The largest single digit is the last 6 symbols are, unfortunately, identical to the letters to the letters of the alphabet.
Each position in an octal number represents a power of the base (16). Therefore equivalent of the octal number 2057 written as 205716 is
· And Hexadecimal base is 16 so in binary form 16 = 24 so conversion of binary to Hexadecimal group of 4 digits each starting from the binary point and proceeding to the left and to the right.
For example: 10110001101011 Where A = 10
10 1100 0110 1011 B=11 2 12 6 11 C = 12 2 C 6 B D = 13
E = 14
= (2C6B)16 F= 15
Conversion:
1. Decimal to Binary Number:
Q1. Convert decimal 41 to binary:
Or, 4110 = X 2
Solution:
First 41 is divided by 2 to give an integer quotient of 20 and a remainder is 1. The quotient is again divided by 2 to give a new quotient and remainder. This process is continued until the integer quotient becomes 0. The coefficients of the desired binary number are obtained from the remainders as follows:
Integer Quotient remainder
41/2 1(LSB) Least Significant Bit
20/2 0
10/2 0
5/2 1
2/2 0
½ 1(MSB) 1010012 = answer
MSB = Most significant Bit
Fraction or Decimal point:
Q1. Convert decimal fraction 0.8125 to binary fraction:
Or, 0.812510 = X 2
Solution:
To convert a decimal fraction to its binary equivalent we use the technique of successive multiplication by 2.
The integer part is noted down after multiplication by 2 at each stage and the reminder new fraction is used for multiplication by 2 at the next stage.
As follows:
Fraction: Fraction X 2 Remainder New Fraction Integer
0.8125 1.625 0.625 1 (MSB)
0.625 1.25 0.25 1
0.25 0.50 0.50 0
0.50 1.00 0.00 1 (LSB)
So, 0.8125(decimal) = 0.1101 (binary)
2. Binary to Decimal Number
Q. Convert binary 101001 to Decimal
Or, 1010012 = X10
Solution:
The first bit counting from the right hand side 20, 21, 22, 23, 24, 25 and so on.
=1 X 25 + 0 X 24 +1 X 23+0 X 22 +0 X 21 +1 X 20
= 32 + 0 + 8 + 0 + 0 + 1
= 4110 answer.
Fraction or Decimal point:
Q1. Convert binary fraction 0.1101 to decimal fraction:
Or, 0.11012 = X 10
Solution:
0.1101= 1 X 2-1 + 1 X 2-2 +0 X 2-3 +1 X 2-4
= 1 X ½ + 1 X 1/4 + 0 X 1/8 + 1 X 1/16
= ½ + ¼ + 0 + 1/16
= 0.5 + 0.25 + 0.0625
= 0.8125 (decimal)
3. Decimal to Octal:
For the conversion of a decimal number to an equivalent octal number, the technique of repeated division by 8 is used. This is explained in a following example:
Q1. Convert decimal 63 to its equivalent Octal number:
Or, 63 10 = X8
Solution:
Quotient Remainder
63/8 =7 7 (LSD)
7/8 =0 7(MSD)
63 10 = 778 answer
Fraction or Decimal point:
Q1. Convert decimal fraction 0.96 to octal fraction:
Or, 0.9610 = X 8
Fraction: Fraction X 8 Remainder New Fraction Integer
0.96 7.68 0.68 7 (MSD)
0.68 5.44 0.44 5
0.44 3.52 0.52 3
0.52 4.16 0.16 4
0.16 1.28 0.28 1 (LSD)
This process will continue further, so we may take the result up to 5 places of octal Point.
0.9610 = 0.754318 answer
4. Octal to Decimal:
Q1. Convert octal 578 to its equivalent decimal number:
Or, 578 = X10
Solution:
As the base of the octal number system is 8, applying the general rule of conversion, we get:
578 = 5 X 81 + 7 X 80
= 5 X 8 + 7 X 1
= 40 + 7
= 47(decimal) answer.
Fraction or Decimal point:
Q1. Convert decimal fraction 0.563 to octal fraction:
Or, 0.5638 = X 10
Solution:
=5 X 8-1 + 6 X 8-2 + 3 X 8-3
= 5 X 1/8 + 6 X 1/64 +3 X 1/512
= 5 X 0.125 + 6 X 0.015625 + 3 X 0.00195
= 0.625 + 0.09375 + 0.005859375
= 0.72460937510 answer
5. Decimal to Hexadecimal
For the conversion of a decimal number to an equivalent Hexadecimal Number, the technique of repeated division by 16 is used. This is explained in a following example:
Q1. Convert decimal 1207 to its equivalent Hexadecimal number:
Or, 1207 10 = X16
Solution:
Quotient Remainder
1207/16 =75 7 (LSD)
75/16 =4 11
4/16 =0 4 (MSD)
= 4117 or 4B7
1207 10 = 4B716 answer
Fraction or Decimal point:
Q1. Convert decimal fraction 0.96 to Hexadecimal fraction:
Or, 0.9610 = X 16
Fraction: Fraction X 16 Remainder New Fraction Integer
0.96 15.36 0.36 15 (MSD)
0.36 5.76 0.76 5
0.76 12.16 0.16 12
0.16 8.96 0.96 8
0.96 15.36 0.36 15 (LSD)
This process will continue further, so we may take the result up to 5 places of octal Point.
0.9610 = 0.1551281516 answer
=0.F5C8F16
Hexadecimal to Decimal
Q1. Convert Hexadecimal 4B716 to its equivalent decimal number:
Or, 4B716 = X10
Solution:
As the base of the Hexadecimal number system is 16, applying the general rule of conversion, we get:
4B716 = 4 X 162 + B X 161 + 7 X 160
= 4 X 256 + 11 X 16 + 7
= 1024 + 176 + 7
= 1207
= 1207(decimal) answer.
Fraction or Decimal point:
Q1. Convert decimal fraction 0.563 to Hexadecimal fraction:
Or, 0.56316 = X 10
Solution:
=5 X 16-1 + 6 X 16-2 + 3 X 16-3
= 5 X 1/16 + 6 X 1/256 +3 X 1/4096
= 5 X 0.625 + 6 X 0.00390 + 3 X 0.00024
= 3.125 +0.0234 + 0.00072
=3.1491210 answer
Binary to Octal Numbers:
The octal number system is a base 8 system. As 8= 23, for binary to octal conversion, group of 3 binary bits each are formed in the binary number starting from right to left. After forming the groups, each group of 3 binary bits is converted to its octal equivalent.
Q. Convert binary 101111 to Decimal
Or, 1011112 = X10
Solution:
We form groups of 3 bits each of the binary of the binary number starting from right to left.
Thus (101111)2
= (101) (111)
=57(octal) answer
Real (Fraction) or Decimal point:
Q1. Convert binary fraction 1011.1011 to octal fraction:
Or, 1011.10112 = X 8
Solution:
1011.1011= (1)(011).(101)(1)
= (001)(011).(101)(100)
= (1) (3).(5)(4)
= 13.54(octal) answer
Octal to Binary Numbers:
To convert an octal number to its equivalent binary number each digit of the given octal number is converted to its 3-bit binary equivalent. This will be clear from the following examples:-
Q. Convert 375 to its equivalent binary number
Or, 3758 = X2
Solution:
(375)8 = (3) (7)(5)
= (011) (111) (101)
= (011111101)2 answer
Real (Fraction) or Decimal point:
Q1. Convert octal fraction (56.35)8 to binary fraction:
Or, (56.35)8 = X 2
Solution:
(56.35)8 = (101)(110).(011)(101)
= (101110.011101)2 answer
Binary to Hexadecimal Numbers:
The Hexadecimal number system is a base 16 system. As 16= 24, for binary to Hexadecimal conversion, group of 4 binary bits each are formed in the binary number starting from right to left. After forming the groups, each group of 4 binary bits is converted to its Hexadecimal equivalent.
Q. Convert binary 101111 to Decimal
Or, 1011112 = X 16
Solution:
We form groups of 4 bits each of the binary of the binary number starting from right to left.
Thus (101111)2
= (0010) (1111)
(2)(15)
=2F (Hexadecimal) answer
Real (Fraction) or Decimal point:
Q1. Convert binary fraction 1011.1011 to octal fraction:
Or, 11011.101112 = X 16
Solution:
11011.10111= (0001)(1011).(1011)(1000)
= (1) (11).(11)(8)
= 1B.B8 (Hexadecimal) answer
Hexadecimal to Binary Numbers:
To convert a hexadecimal number is converted to its 4-bit binary equivalent
For example:
Q. Convert Hexadecimal 2F to binary
Or, 2F16 = X 2
Solution:
2F16 = (2)(F)
= (0010)(1111)
= (101111)2 answer
Real (Fraction) or Decimal point:
Q1. Convert hexadecimal fraction 1B.B8 to binary fraction:
Or, 1B.B816 = X 2
Solution:
1B.B816 = (0001)(1011).(1011)(1000)
= (11011).(10111000)
= (11011).(10111)2 answer
Octal to Hexadecimal Numbers:
To change octal to hexadecimal first we have to change binary number then form 4 binary bits.
Q. Convert 3DF octal to its equivalent hexadecimal number
Or, 376 8 = X16
Solution:
(376)8 = (3) (7)(6)
= (011) (111) (110)
= (011111110)2
This binary equivalent is divided into groups of 4 bits each to obtain its hexadecimal
Equivalent (1111)(1110)
= (15)(14)
= FE16 answer
Real (Fraction) or Decimal point:
Q1. Convert octal fraction (6B.3A)8 to hexadecimal fraction:
Or, (56.35)8 = X 16
Solution:
(56.35)8 = (101)(110).(011)(101)
= (101110.011101)2
= (0010) (1110). (0111) (0100)
= 214.7416 answer
Hexadecimal to Octal Numbers:
The conversion of a hexadecimal number to its equivalent octal number or vice-versa is done through binary conversion as follows:
Q. Convert FE hexadecimal to its equivalent octal number
Or, FE 16 = X 8
Solution:
FE 16 = (15) (14)
= (1111) (1110)
= (11111110)2
This binary equivalent is divided into groups of 3 bits each to obtain its octal
Equivalent (011)(111)(110)
= (3)(7)(6)
= 3768 answer
Real (Fraction) or Decimal point:
Q1. Convert hexadecimal fraction 214.7416 to octal fraction:
Or 214.7416 = X 8
Solution:
214.7416 = (0010)(1110).(0111)(0100)
= (00101110.01110100)2
This binary equivalent is divided into groups of 3 bits each to obtain its octal
= (101)(110).(011)(101)
= 56.358 answer
Integer Representation:
Signed Numbers:
· When an integer binary number is positive the sign is represented by 0 and the magnitude by a positive binary number. For example, consider the signed number 15 stored in an 8-bit register. +15 is represented by a signed bit of 0 in the leftmost position followed by a binary equivalent of 15: 00001111
· When the number is negative the sign is represented by 1 but the rest of the number may be represented in one of three positive ways:-
1. Signed-magnitude representation
15: 1 00001111
Complements are used in digital computers for simplifying the subtraction operation and for logic manipulations. There are two types of complement for each signed 1s’ complement, and signed-2’s’ complement
2. Signed-1’s complement representation
In 1’s complements since only things to be done is to change 0’s into 1’s and 1’s into 0’s.
Complements of 15 represent as 8 bits represent
1’s: 11111111
15: -00001111
` 1 11110000
3. Signed-2’s complement representation
In 2’s complements must be obtained in two ways
(a) By adding 1 to the least significant digit of the 1’s complement
(b) By leaving all leading 0’s in the least significant positions and the
First 1’s unchanged and to changing all 0’s into 1’s and 1’s into 0’s.
1’s complement: 11110000
+ 1
______________
1 11110001
Or, 15: 00001111
= 1 11110001
Arithmetic Addition:
The addition of two numbers in the signed magnitude system follows the rules of ordinary arithmetic.
If the signs are the same, we add the two magnitudes and give the sum the common sign.
If the signs are different we subtract the smaller magnitude from the larger and give the result the sign of the larger magnitude.
For example,
(+15) + (-27) = - (27-15) = -12
2’s complement Addition: Adding numbers in the signed 2’s complement system does not require a comparison or subtraction, only addition and complementation. The procedure is very simple and can be stated as follows: Add the two numbers, including their sign bits, and discard any carry out of the sign (leftmost) bit position, negative numbers must initially be in 2’s complement and that if the sum obtained after the addition is negative, it is in 2’s complement form.
Example,
+ 7 00000111
+14 00001110
______________________
+ 21 000010101
+6 00000110 11111111
-14 11110010 00001110
________________ ` ---------------------
-8 11111000 1111 0001
+1
---------------------
(2’s complement) 11110010
In each of the four cases, the operation performed is always addition, including the sign bits. Any carry out of the sign bit position is discarded, and negative results are automatically in 2’s complement form.
2’s complement Subtraction:
Subtraction of two signed binary when negative numbers are in 2’s complement form is very simple and can be stated as follows: Take the 2’s complement form is very simple and can be stated as follows:
Take the 2’s complement of the subtrahend (including sign bit) and add it to the minuend including the sign bit. A carry out of the sign bit position is discarded.
This is determined by following relationship:
(+- A) – (+B) (+-A) +(-B)
(+- A) – (-B) (+-A) +(+B)
for example (-16)-(-23) = +7
In binary with 8 bit is written as 16: 00010000
1, s coml. 11101111
+1
2,s coml. 11110000
In binary with 8 bit is written as 23: 00010111
1, s coml. 11101000 +1
2,s coml. 11101001
so, 11110000 11110000
- 11101001 + 00010111
------------------- ------------------
00000111 (+7) answer.
r’s Complements:
Given a positive number N in base r with an integer part of n digits, the r’s complement of N is defined as rn – N for N / 0 and 0 for N=0.
For Example
The 10’s complement of (52530) 10 is 10 5 – 52530 = 47480
The 10’s complement of (0.5253) 10 is 1 – 0.5253 = 4747
The 2’s complement of (110011) 2 is (2 6)10 – 110011 =1000000-110011= 001101
r-1’s Complements:
Given a positive number N in base r with an integer part of n digits and a fraction part of m digits, the (r-1)’s complement of N is defined as rn – r-m -N..
For Example
The 9’s complement of (52530) 10 is (10 5 –1- 52530) = 47469
The 9’s complement of (0.5253) 10 is (1-10 -4 – 0.5253) = 0.9999-0.5253=0.4746
The 1’s complement of (110011) 2 is (2 6 - 1) – 110011 =111111-110011= 001100
=/
Overflow:
When numbers of n digits each are added and the sum occupies n+ 1 digit, we say that an overflow occurred. When the addition is performed with paper and pencil, an overflow is not a problem since there is no limit to the width of the page to write down the sum. An overflow is a problem in digit computers because the width of register is finite. A result that contains n + 1 bits cannot be accommodated in a register with a standard length of n bits. For this reason, many computers detect the occurrence of an overflow, and when it occurs a corresponding flip-flop is set which can then be checked by the user.
An overflow cannot occur after an addition if one number is positive and the other is negative, since adding a positive number to negative number produces a result that is smaller than of the two original numbers.
An overflow is occurred if the two numbers added are both positive or both negative.
For example + 75
And + 85
Are stored in 8-bit register the range of numbers that each register can accommodate is from binary +127 to binary -128 since the sum of two number is +160, it exceeds the capacity of the 8-bit register. This is true if the numbers are both positive and both negative.
The two additions in binary are shown below together with the last two carries.
Carries: 0 1
+75 0 1001011
+85 0 1010101
________________
+160 1 0100000
Carries: 1 0
-75 1 0110101
-85 1 0101011
________________
-160 0 1100000
if however, the carry out of the sign bit position is taken as the sign bit of the result , the 9 bit answer so obtained will be correct. Since the answer cannot be accommodated within 8 bits, we say that an overflow occurred.
Floating –Point Representation:
The floating-point representation of a number has two parts.
1. Mantissa: The first part represents a signed, Fixed-point number called the mantissa.
2. Exponent: The second part designates the position of the decimal (or binary) point and is called the exponent. The fixed-point mantissa may be a fraction or an integer.
For example, the decimal number + 5132.789 is represented in floating-point with a fraction and a exponent as follows:
Fraction Exponent
+ 0.5132789 +04
The value of the exponent indicates that the actual position of the decimal point is four positions to the right of the indicated point in the fraction. This represents is equivalent to the scientific notation
+ 0.5132789 X 104
* Floating Point is always interpreted to represent a number in the following form:
m X re Only the mantissa m and the exponent e are physically represented in the register, the radix r and the radix-point position of the mantissa are always assumed.
Fraction:
A floating-point binary number is represented in a similar manner except that it uses base 2 for the exponent.
For example, the binary number +1011.11 is represented with an 8-bit fraction and 6-bit exponent as follows:
Fraction Exponent
01011110 000100
The fraction has a 0 in the leftmost position to denote positive. The binary point of the fraction follows the sign bit but is not shown in the register. The exponent has the equivalent binary number +4. The floating-point number is equivalent to
m X 2e = + 01011110)2 X 2+4
Normalization:
A floating-point is said to be normalized if the most significant digit of the mantissa is nonzero. For example, the decimal number 550 is normalized but 00055 is not. Regardless of where the position of the radix point is assumed to be in the mantissa, the number is normalized only if its leftmost digit is nonzero. For example, the 8-bit binary number 00111010 is not normalized of the two leading 0’s. The number can be normalized by shifting it two positions to the left and discarding the leading 0’s to obtain 11101000 two shifts multiply the number by 22 = 8. To keep the same value for the floating point number, the exponent must be subtracted by 3. Normalized numbers provide the maximum possible precision for the floating-point number.
A number cannot be normalized because it does not have a nonzero digit
Character Codes:
Many applications of digital computers require the handling of data that consist not only of numbers, but also of the letters of the alphabet and certain special character. An alphanumeric character set is a set of elements that includes the 10 decimal digits, the 26 letters of the alphabet and a number of special characters, such as $, +, and =. Such a set contains between 32 and 64 elements or 64 and 128 with both uppercase and lowercase letters are included.
Binary Code:
Electronics digital systems use signals that have two distinct values and circuit elements that have two stable states. There is a direct analog among binary signals, binary circuit elements and binary digits.
A binary number of n digits, for example, may be represented by n binary circuit elements, each having an output signal equivalent to 0 or 1.
A bit by definition, is a binary digit? When used in conjunction with a binary code, it is better to think of it as denoting a binary quantity equal to 0 or 1.
To represent a group of 2n distinct elements in a binary code requires a minimum of n bits this is because it is possible to arrange n bits in 2n distinct ways.
For example, a group of four distinct quantities can be represented by a two bit code with following bit combinations: 00,01,10,11.
A group of eight elements requires a three bit code, with each element assigned to one and only one of the following:
000, 001,010,011,100,101,110,111
Decimal Codes
Binary code for decimal digits requires a minimum of four bits. Numerous different codes can be obtained by arranging four or more bits in ten distinct possible combinations.
Decimal number (BCD)
8421
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
The BCD (binary-coded decimal) is a straight assignment of the binary equivalent. It is possible to assign weights to the binary bits according to their positions. The weight in the BCD code are 8,4,2,1 the bit assignment 0110, for example can be interpreted by weights to represent the decimal digit 6 because 0 X 8 +1 X 4 + 1 X 2 + 0 X 1 = 6. It is also possible to assign negative weights to a decimal code
Numbers are represented in digital computers either in binary or in decimal through a binary code. When specifying data, the user likes to give the data in decimal code. Each decimal digit requires at least four binary storage elements. The decimal numbers converted to binary when arithmetic operations are done internally with numbers represented in binary.
ASCII (American Standard Code for Information Interchange):
Which seven bits to code 128 characters. The binary code for the uppercase letters, the decimal digits, and a few special characters is listed below.
The decimal digits in ASCII can be converted to BCD by removing the three high order bits 011.
Binary codes play an important part in digital computer operations. The codes must be in binary because registers can only hold binary information. One must realize that binary codes merely change the symbols, not the meaning of the discrete elements they represent. The operations specified for digital computers must take into consideration the meaning of the bits stored in registers so that operations are performed on operands of the same type. In inspecting the bits of a computer register at random, one is likely to find that it represents some type of coded information rather than a binary number.
Some few characters are shown in Table below:
Character ASCII code
7 bit
----------- --------------
A 100 0001
B 100 0010
C 100 0011
D 100 0100
E 100 0101
F 100 0110
-- -----------
-- -- ---
Z 101 1010
0 011 0000
-- -- ---
9 011 1001
Include special characters such as blank, . , (, ) etc.
EBCDIC (Extended BCD Interchange Code):
It uses eight bits for each character and a nine bit for parity. EBCDIC has the same characters symbols as ASCII but the bit assignment to characters is different.
When alphanumeric characters are used internally in a computer for data processing (not for transmission purpose) it is more convenient to use a 6-bit code bit to represent 64 characters. A 6-bit code can specify the 26 uppercase letters of the alphabet, numerals zero to nine, and up to 28 special characters. This set of characters is usually sufficient for data processing purpose.
Some few characters are shown in Table below:
Character ASCII code
8 bit
----------- --------------
A 1100 0001
B 1100 0010
C 1100 0011
D 1100 0100
E 1100 0101
F 1100 0110
-- -----------
-- -- ---
Z 1110 1001
0 1111 0000
-- -- ---
9 1111 1001
Include special characters such as blank, . , (, ) etc
Error Detection Codes:
Binary information transmitted through some form of communication medium is subject to external noise that could change bits from 1 to 0, vice versa. Due to this information can be changed from its original information so we need error detection code to overcome these problems. An error detection code is a binary code that detects digital errors during transmission.
The detected errors cannot be corrected but their presence is indicated. The usual procedure is to observe the frequency of errors. If errors occur infrequently at random, the particular erroneous information is transmitted again, checked for malfunction.
Parity bit:
The Parity bit is the used as a most error detection code. It is an extra bit included with a binary message to make the total number of 1’s either odd or even. The P(odd) bit is chosen to make the sum of 1,s (in all four bits) odd. The P (even) bit is chosen to make the sum of all 1’s even during transfer of information from one location to another. But combination of all 0’s while in the odd parity there is always one bit that is 1.
Message
xyz P(odd) P(even)
_________________________________________
000 1 0
001 0 1
010 0 1
011 1 0
100 0 1
101 1 0
110 1 0
111 0 1
parity generator:
At the sending end, the message is applied to a parity generator, where the required parity bit is generated. The message, including the parity bit, is transmitted to its destination. At the receiving end, all the incoming bits are applied to a parity checker that checks the proper parity adopted.
parity checker:
That checks the proper parity adopted weather odd or even. An error is detected if the checked parity does not conform to the adopted parity. The parity methods the presence of one, three, or any odd number of errors. An even number of errors is not detected.
Odd function: An odd function is a logic function whose value is binary 1 if and only if, and only if, an function is the exclusive-OR of x, y, and z because it is equal to 1 when either one or all three of the variables are equal to 1. The p(Odd) function is the complement of the P (even) function.
Figure
The most widely used number system is the positional system. In this system position of a digit indicates the significance to be attached to that digit. Positional Number systems have a radix or a base.
Positional Number systems are:-
Decimal Number
Binary Number
Octal Number
Hexadecimal Number
The non-positional number system with which all of us are familiar is the Roman number systems. This number system is difficult to use as it has no symbol for zero. The Idea of positional value number system was the greatest invention of this age and this came from India. In the words of Marquis De Laplace, the great mathematician.
Decimal Numbers:
In the decimal number system there are ten digits which are used to form decimal Numbers. Ten unique symbols 0, 1, 2,3,4,5,6,7,8 and 9 are used to represent ten
Decimal digits. Human beings have always used them in counting. So the decimal Number system followed naturally from the use of our fingers, the base or radix of a number system is defined as the number of digits it uses to represent numbers in the systems. Since the decimal number system uses ten digits, from 0 to 9, its base or radix is 10. The decimal number system is also called base-10 number system.
The string of digits 724.5 is interpreted to represent the quantity
7 X 102 + 2 X 101 + 4 X 100 + 5 X 10-1
That is 7 hundreds, plus 2 tens, plus 4 units, plus 5 tenths.
In general, a number with a decimal point is represented by a series of coefficients as follows:
a5 a4 a3 a2 a1 a0. a-1 a-2 a-3
The power of 10 by which the coefficient must be multiplied
105a5 + 104 a4 +103 a3 + 102 a2 + 101 a1 + 100 a0 + 10-1 a-1 + 10-2 a-2 +10-3 a-3
Binary Numbers(or Base 2 system):
The binary number system uses only two digits, 0 and 1 In short a binary digit is called a bit. The storing or computing electronic elements of a computer have only two stable states. The output of such electronic circuit at any time is either HIGH or LOW. These states can be represent by 1 and 0 respectively, that is HIGH is represented by 1 and LOW by 0.Due to this characteristics of electronic circuits, a computer can understand information composed of only 0s and 1s. So all computers perform their internal manipulations on binary digits. But the programmers use data and other information in the form of decimal digits, alphabets and special symbols.
The decimal equivalent of the binary number 11010.11 is 26.75 as follows-
=1 X 24 + 1 X 23 + 0 X 22 + 1 X 21 + 0 X 20 + 1 X 2-1 + 1 X 2-2
= 16 + 8 + 0 + 2 + 0 + ½ + ¼
=26.75
In general, a number expressed in base-r system has coefficients multiplied by power of r:
an.. rn + a n-1 . r n-1 + ………..+ a2. r2 + a1. r + a0
Example of Addition, Subtraction and multiplication of two binary numbers are shown below:
Addition: carry 1111
augend: 101101
addend : + 100111
____________
sum: 1010100
Subtraction: carrcy 2 2
minuend: 101101
subtrahend: - 100111
____________
difference 000110
Multiplication:
Multicland: 1011
Multiplier: X 101
_______
1011
0000
1011
___________
110111
Octal Number System:
In the octal number system, the base is 8. Hence, there are only eight symbols or digits: 0,1,2,3,4,5,6 and 7. The largest single digit is 7 (one less than the base)
Each position in an octal number represents a power of the base (8). Therefore equivalent of the octal number 2057 written as 20578 is:
=(2 X 83) + (0 X 82 ) + (5 X 81) + (7 X 80)
= 2 X 512 + 0 + 40 + 7
= 1024 + 47
= 107110
· Since octal base is 8 so in binary form 8 = 23 so conversion of binary to octal group of 3 digits each starting from the binary point and proceeding to the left and to the right.
For example: 10110001101011
10 110 001 101 011
2 6 1 5 3
= (26153)8
Hexadecimal Number System:
In the Hexadecimal number system, the base is 16. Hence, there are sixteen symbols or digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F. The largest single digit is the last 6 symbols are, unfortunately, identical to the letters to the letters of the alphabet.
Each position in an octal number represents a power of the base (16). Therefore equivalent of the octal number 2057 written as 205716 is
· And Hexadecimal base is 16 so in binary form 16 = 24 so conversion of binary to Hexadecimal group of 4 digits each starting from the binary point and proceeding to the left and to the right.
For example: 10110001101011 Where A = 10
10 1100 0110 1011 B=11 2 12 6 11 C = 12 2 C 6 B D = 13
E = 14
= (2C6B)16 F= 15
Conversion:
1. Decimal to Binary Number:
Q1. Convert decimal 41 to binary:
Or, 4110 = X 2
Solution:
First 41 is divided by 2 to give an integer quotient of 20 and a remainder is 1. The quotient is again divided by 2 to give a new quotient and remainder. This process is continued until the integer quotient becomes 0. The coefficients of the desired binary number are obtained from the remainders as follows:
Integer Quotient remainder
41/2 1(LSB) Least Significant Bit
20/2 0
10/2 0
5/2 1
2/2 0
½ 1(MSB) 1010012 = answer
MSB = Most significant Bit
Fraction or Decimal point:
Q1. Convert decimal fraction 0.8125 to binary fraction:
Or, 0.812510 = X 2
Solution:
To convert a decimal fraction to its binary equivalent we use the technique of successive multiplication by 2.
The integer part is noted down after multiplication by 2 at each stage and the reminder new fraction is used for multiplication by 2 at the next stage.
As follows:
Fraction: Fraction X 2 Remainder New Fraction Integer
0.8125 1.625 0.625 1 (MSB)
0.625 1.25 0.25 1
0.25 0.50 0.50 0
0.50 1.00 0.00 1 (LSB)
So, 0.8125(decimal) = 0.1101 (binary)
2. Binary to Decimal Number
Q. Convert binary 101001 to Decimal
Or, 1010012 = X10
Solution:
The first bit counting from the right hand side 20, 21, 22, 23, 24, 25 and so on.
=1 X 25 + 0 X 24 +1 X 23+0 X 22 +0 X 21 +1 X 20
= 32 + 0 + 8 + 0 + 0 + 1
= 4110 answer.
Fraction or Decimal point:
Q1. Convert binary fraction 0.1101 to decimal fraction:
Or, 0.11012 = X 10
Solution:
0.1101= 1 X 2-1 + 1 X 2-2 +0 X 2-3 +1 X 2-4
= 1 X ½ + 1 X 1/4 + 0 X 1/8 + 1 X 1/16
= ½ + ¼ + 0 + 1/16
= 0.5 + 0.25 + 0.0625
= 0.8125 (decimal)
3. Decimal to Octal:
For the conversion of a decimal number to an equivalent octal number, the technique of repeated division by 8 is used. This is explained in a following example:
Q1. Convert decimal 63 to its equivalent Octal number:
Or, 63 10 = X8
Solution:
Quotient Remainder
63/8 =7 7 (LSD)
7/8 =0 7(MSD)
63 10 = 778 answer
Fraction or Decimal point:
Q1. Convert decimal fraction 0.96 to octal fraction:
Or, 0.9610 = X 8
Fraction: Fraction X 8 Remainder New Fraction Integer
0.96 7.68 0.68 7 (MSD)
0.68 5.44 0.44 5
0.44 3.52 0.52 3
0.52 4.16 0.16 4
0.16 1.28 0.28 1 (LSD)
This process will continue further, so we may take the result up to 5 places of octal Point.
0.9610 = 0.754318 answer
4. Octal to Decimal:
Q1. Convert octal 578 to its equivalent decimal number:
Or, 578 = X10
Solution:
As the base of the octal number system is 8, applying the general rule of conversion, we get:
578 = 5 X 81 + 7 X 80
= 5 X 8 + 7 X 1
= 40 + 7
= 47(decimal) answer.
Fraction or Decimal point:
Q1. Convert decimal fraction 0.563 to octal fraction:
Or, 0.5638 = X 10
Solution:
=5 X 8-1 + 6 X 8-2 + 3 X 8-3
= 5 X 1/8 + 6 X 1/64 +3 X 1/512
= 5 X 0.125 + 6 X 0.015625 + 3 X 0.00195
= 0.625 + 0.09375 + 0.005859375
= 0.72460937510 answer
5. Decimal to Hexadecimal
For the conversion of a decimal number to an equivalent Hexadecimal Number, the technique of repeated division by 16 is used. This is explained in a following example:
Q1. Convert decimal 1207 to its equivalent Hexadecimal number:
Or, 1207 10 = X16
Solution:
Quotient Remainder
1207/16 =75 7 (LSD)
75/16 =4 11
4/16 =0 4 (MSD)
= 4117 or 4B7
1207 10 = 4B716 answer
Fraction or Decimal point:
Q1. Convert decimal fraction 0.96 to Hexadecimal fraction:
Or, 0.9610 = X 16
Fraction: Fraction X 16 Remainder New Fraction Integer
0.96 15.36 0.36 15 (MSD)
0.36 5.76 0.76 5
0.76 12.16 0.16 12
0.16 8.96 0.96 8
0.96 15.36 0.36 15 (LSD)
This process will continue further, so we may take the result up to 5 places of octal Point.
0.9610 = 0.1551281516 answer
=0.F5C8F16
Hexadecimal to Decimal
Q1. Convert Hexadecimal 4B716 to its equivalent decimal number:
Or, 4B716 = X10
Solution:
As the base of the Hexadecimal number system is 16, applying the general rule of conversion, we get:
4B716 = 4 X 162 + B X 161 + 7 X 160
= 4 X 256 + 11 X 16 + 7
= 1024 + 176 + 7
= 1207
= 1207(decimal) answer.
Fraction or Decimal point:
Q1. Convert decimal fraction 0.563 to Hexadecimal fraction:
Or, 0.56316 = X 10
Solution:
=5 X 16-1 + 6 X 16-2 + 3 X 16-3
= 5 X 1/16 + 6 X 1/256 +3 X 1/4096
= 5 X 0.625 + 6 X 0.00390 + 3 X 0.00024
= 3.125 +0.0234 + 0.00072
=3.1491210 answer
Binary to Octal Numbers:
The octal number system is a base 8 system. As 8= 23, for binary to octal conversion, group of 3 binary bits each are formed in the binary number starting from right to left. After forming the groups, each group of 3 binary bits is converted to its octal equivalent.
Q. Convert binary 101111 to Decimal
Or, 1011112 = X10
Solution:
We form groups of 3 bits each of the binary of the binary number starting from right to left.
Thus (101111)2
= (101) (111)
=57(octal) answer
Real (Fraction) or Decimal point:
Q1. Convert binary fraction 1011.1011 to octal fraction:
Or, 1011.10112 = X 8
Solution:
1011.1011= (1)(011).(101)(1)
= (001)(011).(101)(100)
= (1) (3).(5)(4)
= 13.54(octal) answer
Octal to Binary Numbers:
To convert an octal number to its equivalent binary number each digit of the given octal number is converted to its 3-bit binary equivalent. This will be clear from the following examples:-
Q. Convert 375 to its equivalent binary number
Or, 3758 = X2
Solution:
(375)8 = (3) (7)(5)
= (011) (111) (101)
= (011111101)2 answer
Real (Fraction) or Decimal point:
Q1. Convert octal fraction (56.35)8 to binary fraction:
Or, (56.35)8 = X 2
Solution:
(56.35)8 = (101)(110).(011)(101)
= (101110.011101)2 answer
Binary to Hexadecimal Numbers:
The Hexadecimal number system is a base 16 system. As 16= 24, for binary to Hexadecimal conversion, group of 4 binary bits each are formed in the binary number starting from right to left. After forming the groups, each group of 4 binary bits is converted to its Hexadecimal equivalent.
Q. Convert binary 101111 to Decimal
Or, 1011112 = X 16
Solution:
We form groups of 4 bits each of the binary of the binary number starting from right to left.
Thus (101111)2
= (0010) (1111)
(2)(15)
=2F (Hexadecimal) answer
Real (Fraction) or Decimal point:
Q1. Convert binary fraction 1011.1011 to octal fraction:
Or, 11011.101112 = X 16
Solution:
11011.10111= (0001)(1011).(1011)(1000)
= (1) (11).(11)(8)
= 1B.B8 (Hexadecimal) answer
Hexadecimal to Binary Numbers:
To convert a hexadecimal number is converted to its 4-bit binary equivalent
For example:
Q. Convert Hexadecimal 2F to binary
Or, 2F16 = X 2
Solution:
2F16 = (2)(F)
= (0010)(1111)
= (101111)2 answer
Real (Fraction) or Decimal point:
Q1. Convert hexadecimal fraction 1B.B8 to binary fraction:
Or, 1B.B816 = X 2
Solution:
1B.B816 = (0001)(1011).(1011)(1000)
= (11011).(10111000)
= (11011).(10111)2 answer
Octal to Hexadecimal Numbers:
To change octal to hexadecimal first we have to change binary number then form 4 binary bits.
Q. Convert 3DF octal to its equivalent hexadecimal number
Or, 376 8 = X16
Solution:
(376)8 = (3) (7)(6)
= (011) (111) (110)
= (011111110)2
This binary equivalent is divided into groups of 4 bits each to obtain its hexadecimal
Equivalent (1111)(1110)
= (15)(14)
= FE16 answer
Real (Fraction) or Decimal point:
Q1. Convert octal fraction (6B.3A)8 to hexadecimal fraction:
Or, (56.35)8 = X 16
Solution:
(56.35)8 = (101)(110).(011)(101)
= (101110.011101)2
= (0010) (1110). (0111) (0100)
= 214.7416 answer
Hexadecimal to Octal Numbers:
The conversion of a hexadecimal number to its equivalent octal number or vice-versa is done through binary conversion as follows:
Q. Convert FE hexadecimal to its equivalent octal number
Or, FE 16 = X 8
Solution:
FE 16 = (15) (14)
= (1111) (1110)
= (11111110)2
This binary equivalent is divided into groups of 3 bits each to obtain its octal
Equivalent (011)(111)(110)
= (3)(7)(6)
= 3768 answer
Real (Fraction) or Decimal point:
Q1. Convert hexadecimal fraction 214.7416 to octal fraction:
Or 214.7416 = X 8
Solution:
214.7416 = (0010)(1110).(0111)(0100)
= (00101110.01110100)2
This binary equivalent is divided into groups of 3 bits each to obtain its octal
= (101)(110).(011)(101)
= 56.358 answer
Integer Representation:
Signed Numbers:
· When an integer binary number is positive the sign is represented by 0 and the magnitude by a positive binary number. For example, consider the signed number 15 stored in an 8-bit register. +15 is represented by a signed bit of 0 in the leftmost position followed by a binary equivalent of 15: 00001111
· When the number is negative the sign is represented by 1 but the rest of the number may be represented in one of three positive ways:-
1. Signed-magnitude representation
15: 1 00001111
Complements are used in digital computers for simplifying the subtraction operation and for logic manipulations. There are two types of complement for each signed 1s’ complement, and signed-2’s’ complement
2. Signed-1’s complement representation
In 1’s complements since only things to be done is to change 0’s into 1’s and 1’s into 0’s.
Complements of 15 represent as 8 bits represent
1’s: 11111111
15: -00001111
` 1 11110000
3. Signed-2’s complement representation
In 2’s complements must be obtained in two ways
(a) By adding 1 to the least significant digit of the 1’s complement
(b) By leaving all leading 0’s in the least significant positions and the
First 1’s unchanged and to changing all 0’s into 1’s and 1’s into 0’s.
1’s complement: 11110000
+ 1
______________
1 11110001
Or, 15: 00001111
= 1 11110001
Arithmetic Addition:
The addition of two numbers in the signed magnitude system follows the rules of ordinary arithmetic.
If the signs are the same, we add the two magnitudes and give the sum the common sign.
If the signs are different we subtract the smaller magnitude from the larger and give the result the sign of the larger magnitude.
For example,
(+15) + (-27) = - (27-15) = -12
2’s complement Addition: Adding numbers in the signed 2’s complement system does not require a comparison or subtraction, only addition and complementation. The procedure is very simple and can be stated as follows: Add the two numbers, including their sign bits, and discard any carry out of the sign (leftmost) bit position, negative numbers must initially be in 2’s complement and that if the sum obtained after the addition is negative, it is in 2’s complement form.
Example,
+ 7 00000111
+14 00001110
______________________
+ 21 000010101
+6 00000110 11111111
-14 11110010 00001110
________________ ` ---------------------
-8 11111000 1111 0001
+1
---------------------
(2’s complement) 11110010
In each of the four cases, the operation performed is always addition, including the sign bits. Any carry out of the sign bit position is discarded, and negative results are automatically in 2’s complement form.
2’s complement Subtraction:
Subtraction of two signed binary when negative numbers are in 2’s complement form is very simple and can be stated as follows: Take the 2’s complement form is very simple and can be stated as follows:
Take the 2’s complement of the subtrahend (including sign bit) and add it to the minuend including the sign bit. A carry out of the sign bit position is discarded.
This is determined by following relationship:
(+- A) – (+B) (+-A) +(-B)
(+- A) – (-B) (+-A) +(+B)
for example (-16)-(-23) = +7
In binary with 8 bit is written as 16: 00010000
1, s coml. 11101111
+1
2,s coml. 11110000
In binary with 8 bit is written as 23: 00010111
1, s coml. 11101000 +1
2,s coml. 11101001
so, 11110000 11110000
- 11101001 + 00010111
------------------- ------------------
00000111 (+7) answer.
r’s Complements:
Given a positive number N in base r with an integer part of n digits, the r’s complement of N is defined as rn – N for N / 0 and 0 for N=0.
For Example
The 10’s complement of (52530) 10 is 10 5 – 52530 = 47480
The 10’s complement of (0.5253) 10 is 1 – 0.5253 = 4747
The 2’s complement of (110011) 2 is (2 6)10 – 110011 =1000000-110011= 001101
r-1’s Complements:
Given a positive number N in base r with an integer part of n digits and a fraction part of m digits, the (r-1)’s complement of N is defined as rn – r-m -N..
For Example
The 9’s complement of (52530) 10 is (10 5 –1- 52530) = 47469
The 9’s complement of (0.5253) 10 is (1-10 -4 – 0.5253) = 0.9999-0.5253=0.4746
The 1’s complement of (110011) 2 is (2 6 - 1) – 110011 =111111-110011= 001100
=/
Overflow:
When numbers of n digits each are added and the sum occupies n+ 1 digit, we say that an overflow occurred. When the addition is performed with paper and pencil, an overflow is not a problem since there is no limit to the width of the page to write down the sum. An overflow is a problem in digit computers because the width of register is finite. A result that contains n + 1 bits cannot be accommodated in a register with a standard length of n bits. For this reason, many computers detect the occurrence of an overflow, and when it occurs a corresponding flip-flop is set which can then be checked by the user.
An overflow cannot occur after an addition if one number is positive and the other is negative, since adding a positive number to negative number produces a result that is smaller than of the two original numbers.
An overflow is occurred if the two numbers added are both positive or both negative.
For example + 75
And + 85
Are stored in 8-bit register the range of numbers that each register can accommodate is from binary +127 to binary -128 since the sum of two number is +160, it exceeds the capacity of the 8-bit register. This is true if the numbers are both positive and both negative.
The two additions in binary are shown below together with the last two carries.
Carries: 0 1
+75 0 1001011
+85 0 1010101
________________
+160 1 0100000
Carries: 1 0
-75 1 0110101
-85 1 0101011
________________
-160 0 1100000
if however, the carry out of the sign bit position is taken as the sign bit of the result , the 9 bit answer so obtained will be correct. Since the answer cannot be accommodated within 8 bits, we say that an overflow occurred.
Floating –Point Representation:
The floating-point representation of a number has two parts.
1. Mantissa: The first part represents a signed, Fixed-point number called the mantissa.
2. Exponent: The second part designates the position of the decimal (or binary) point and is called the exponent. The fixed-point mantissa may be a fraction or an integer.
For example, the decimal number + 5132.789 is represented in floating-point with a fraction and a exponent as follows:
Fraction Exponent
+ 0.5132789 +04
The value of the exponent indicates that the actual position of the decimal point is four positions to the right of the indicated point in the fraction. This represents is equivalent to the scientific notation
+ 0.5132789 X 104
* Floating Point is always interpreted to represent a number in the following form:
m X re Only the mantissa m and the exponent e are physically represented in the register, the radix r and the radix-point position of the mantissa are always assumed.
Fraction:
A floating-point binary number is represented in a similar manner except that it uses base 2 for the exponent.
For example, the binary number +1011.11 is represented with an 8-bit fraction and 6-bit exponent as follows:
Fraction Exponent
01011110 000100
The fraction has a 0 in the leftmost position to denote positive. The binary point of the fraction follows the sign bit but is not shown in the register. The exponent has the equivalent binary number +4. The floating-point number is equivalent to
m X 2e = + 01011110)2 X 2+4
Normalization:
A floating-point is said to be normalized if the most significant digit of the mantissa is nonzero. For example, the decimal number 550 is normalized but 00055 is not. Regardless of where the position of the radix point is assumed to be in the mantissa, the number is normalized only if its leftmost digit is nonzero. For example, the 8-bit binary number 00111010 is not normalized of the two leading 0’s. The number can be normalized by shifting it two positions to the left and discarding the leading 0’s to obtain 11101000 two shifts multiply the number by 22 = 8. To keep the same value for the floating point number, the exponent must be subtracted by 3. Normalized numbers provide the maximum possible precision for the floating-point number.
A number cannot be normalized because it does not have a nonzero digit
Character Codes:
Many applications of digital computers require the handling of data that consist not only of numbers, but also of the letters of the alphabet and certain special character. An alphanumeric character set is a set of elements that includes the 10 decimal digits, the 26 letters of the alphabet and a number of special characters, such as $, +, and =. Such a set contains between 32 and 64 elements or 64 and 128 with both uppercase and lowercase letters are included.
Binary Code:
Electronics digital systems use signals that have two distinct values and circuit elements that have two stable states. There is a direct analog among binary signals, binary circuit elements and binary digits.
A binary number of n digits, for example, may be represented by n binary circuit elements, each having an output signal equivalent to 0 or 1.
A bit by definition, is a binary digit? When used in conjunction with a binary code, it is better to think of it as denoting a binary quantity equal to 0 or 1.
To represent a group of 2n distinct elements in a binary code requires a minimum of n bits this is because it is possible to arrange n bits in 2n distinct ways.
For example, a group of four distinct quantities can be represented by a two bit code with following bit combinations: 00,01,10,11.
A group of eight elements requires a three bit code, with each element assigned to one and only one of the following:
000, 001,010,011,100,101,110,111
Decimal Codes
Binary code for decimal digits requires a minimum of four bits. Numerous different codes can be obtained by arranging four or more bits in ten distinct possible combinations.
Decimal number (BCD)
8421
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
The BCD (binary-coded decimal) is a straight assignment of the binary equivalent. It is possible to assign weights to the binary bits according to their positions. The weight in the BCD code are 8,4,2,1 the bit assignment 0110, for example can be interpreted by weights to represent the decimal digit 6 because 0 X 8 +1 X 4 + 1 X 2 + 0 X 1 = 6. It is also possible to assign negative weights to a decimal code
Numbers are represented in digital computers either in binary or in decimal through a binary code. When specifying data, the user likes to give the data in decimal code. Each decimal digit requires at least four binary storage elements. The decimal numbers converted to binary when arithmetic operations are done internally with numbers represented in binary.
ASCII (American Standard Code for Information Interchange):
Which seven bits to code 128 characters. The binary code for the uppercase letters, the decimal digits, and a few special characters is listed below.
The decimal digits in ASCII can be converted to BCD by removing the three high order bits 011.
Binary codes play an important part in digital computer operations. The codes must be in binary because registers can only hold binary information. One must realize that binary codes merely change the symbols, not the meaning of the discrete elements they represent. The operations specified for digital computers must take into consideration the meaning of the bits stored in registers so that operations are performed on operands of the same type. In inspecting the bits of a computer register at random, one is likely to find that it represents some type of coded information rather than a binary number.
Some few characters are shown in Table below:
Character ASCII code
7 bit
----------- --------------
A 100 0001
B 100 0010
C 100 0011
D 100 0100
E 100 0101
F 100 0110
-- -----------
-- -- ---
Z 101 1010
0 011 0000
-- -- ---
9 011 1001
Include special characters such as blank, . , (, ) etc.
EBCDIC (Extended BCD Interchange Code):
It uses eight bits for each character and a nine bit for parity. EBCDIC has the same characters symbols as ASCII but the bit assignment to characters is different.
When alphanumeric characters are used internally in a computer for data processing (not for transmission purpose) it is more convenient to use a 6-bit code bit to represent 64 characters. A 6-bit code can specify the 26 uppercase letters of the alphabet, numerals zero to nine, and up to 28 special characters. This set of characters is usually sufficient for data processing purpose.
Some few characters are shown in Table below:
Character ASCII code
8 bit
----------- --------------
A 1100 0001
B 1100 0010
C 1100 0011
D 1100 0100
E 1100 0101
F 1100 0110
-- -----------
-- -- ---
Z 1110 1001
0 1111 0000
-- -- ---
9 1111 1001
Include special characters such as blank, . , (, ) etc
Error Detection Codes:
Binary information transmitted through some form of communication medium is subject to external noise that could change bits from 1 to 0, vice versa. Due to this information can be changed from its original information so we need error detection code to overcome these problems. An error detection code is a binary code that detects digital errors during transmission.
The detected errors cannot be corrected but their presence is indicated. The usual procedure is to observe the frequency of errors. If errors occur infrequently at random, the particular erroneous information is transmitted again, checked for malfunction.
Parity bit:
The Parity bit is the used as a most error detection code. It is an extra bit included with a binary message to make the total number of 1’s either odd or even. The P(odd) bit is chosen to make the sum of 1,s (in all four bits) odd. The P (even) bit is chosen to make the sum of all 1’s even during transfer of information from one location to another. But combination of all 0’s while in the odd parity there is always one bit that is 1.
Message
xyz P(odd) P(even)
_________________________________________
000 1 0
001 0 1
010 0 1
011 1 0
100 0 1
101 1 0
110 1 0
111 0 1
parity generator:
At the sending end, the message is applied to a parity generator, where the required parity bit is generated. The message, including the parity bit, is transmitted to its destination. At the receiving end, all the incoming bits are applied to a parity checker that checks the proper parity adopted.
parity checker:
That checks the proper parity adopted weather odd or even. An error is detected if the checked parity does not conform to the adopted parity. The parity methods the presence of one, three, or any odd number of errors. An even number of errors is not detected.
Odd function: An odd function is a logic function whose value is binary 1 if and only if, and only if, an function is the exclusive-OR of x, y, and z because it is equal to 1 when either one or all three of the variables are equal to 1. The p(Odd) function is the complement of the P (even) function.
Figure
No comments:
Post a Comment