CO Unit1 Part2
CO Unit1 Part2
The language we use to communicate with each other is comprised of words and characters. We understand
numbers, characters and words. But this type of data is not suitable for computers. Computers only
understand the numbers.
So, when we enter data, the data is converted into electronic pulse. Each pulse is identified as code and the
code is converted into numeric format by ASCII. It gives each number, character and symbol a numeric
value (number) that a computer understands. So to understand the language of computers, one must be
familiar with the number systems.
It has only two digits '0' and '1' so its base is 2. Accordingly, In this number system, there are only two
types of electronic pulses; absence of electronic pulse which represents '0'and presence of electronic pulse
which represents '1'. Each digit is called a bit. A group of four bits (1101) is called a nibble and group of
eight bits (11001010) is called a byte. The position of each digit in a binary number represents a specific
power of the base (2) of the number system.
It has eight digits (0, 1, 2, 3, 4, 5, 6, 7) so its base is 8. Each digit in an octal number represents a specific
power of its base (8). As there are only eight digits, three bits (23=8) of binary number system can convert
any octal number into binary number. This number system is also used to shorten long binary numbers.
The three binary digits can be represented with a single octal digit.
This number system has ten digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) so its base is 10. In this number system, the
maximum value of a digit is 9 and the minimum value of a digit is 0. The position of each digit in decimal
number represents a specific power of the base (10) of the number system. This number system is widely
used in our day to day life. It can represent any numeric value.
This number system has 16 digits that ranges from 0 to 9 and A to F. So, its base is 16. The A to F
alphabets represent 10 to 15 decimal numbers. The position of each digit in a hexadecimal number
represents a specific power of base (16) of the number system. As there are only sixteen digits, four bits
(24=16) of binary number system can convert any hexadecimal number into binary number. It is also
known as alphanumeric number system as it uses both numeric digits and alphabets.
Binary Arithmetic:
Binary arithmetic is essential part of all the digital computers and many
other digital systems.
Binary Addition
It is a key for binary subtraction, multiplication, division. There are four
rules of binary addition.
Example − Addition
Binary Subtraction
Subtraction and Borrow, these two words will be used very frequently for the
binary subtraction. There are four rules of binary subtraction.
Example − Subtraction
Binary Multiplication
Binary multiplication is similar to decimal multiplication. It is simpler than
decimal multiplication because only 0s and 1s are involved. There are four
rules of binary multiplication.
Example − Multiplication
Binary Division
Binary division is similar to decimal division. It is called as the long division
procedure.
Example − Division
Example-
ADD X will increment the value stored in the accumulator by the value stored at memory location X.
AC ← AC + [X]
Example-
ADD X will increment the value stored in the accumulator by the value stored at memory location
specified by X.
AC ← AC + [[X]]
Example-
ADD R will increment the value stored in the accumulator by the content of register R.
AC ← AC + [R]
Example-
ADD R
will
increment
the value stored in the accumulator by the content of memory location specified in register R.
AC ← AC + [[R]]
8. Indexed Addressing Mode-
In this addressing mode,
Effective address of the operand is obtained by adding the content of index register with the
address part of the instruction.
Example:
We indicate index mode symbolically as x(Ri).Here X denotes the constant value contained in the
instruction.Ri is name of the register.
Add 20(R1),R2
9. Base Register Addressing Mode-
In this addressing mode,
Effective address of the operand is obtained by adding the content of base register with the
address part of the instruction.
This addressing mode is a special case of Register Indirect Addressing Mode where-
But the fact is, computer memory holds instructions and data. And a single bit is very small to hold this
information so bits are rarely used individually. As a solution to this, the bits are grouped in fixed sizes of n
bits. The memory of the computer is organized in such a way that the group of these n bits can be stored
and retrieved easily by the computer in a single operation.
The group of n bit is termed as word where n is termed as the word length. The word length of the
computer has evolved from 8, 16, 24, 32 to 64 bits. General-purpose computers nowadays have 32 to 64
bits. The group of 8 bit is called a byte.
Now, whenever you want to store any instruction or data may it be of a byte or a word you have to access a
memory location. To access the memory location either you must know the memory location by its unique
name or it is required to provide a unique address to each memory location.
The memory locations are addressed from 0 to 2K-1 i.e. a memory has 2 K addressable locations. And thus
the address space of the computer has 2 K addresses. Let us try some suitable values for K.
Byte Addressability
Till now we have gone through three information storing quantities bit, byte and word. We have seen
above that 8 bits together form a byte and this is the fix for every memory. But the word length varies from
memory to memory and it ranges from 16 to 64 bit.
Well, it is impossible to allot a unique address to each bit in memory. As a solution, most modern
computers assign successive addresses to successive byte locations in memory. This assignment of
addresses to individual byte locations is termed byte addressability and memory is referred to as byte-
addressable memory.
If we assign an address to individual byte locations in the memory like 0, 1, 2, 3…. .Now if the word length
of the machine is 16 bit then the successive words are located at addresses 0, 2, 4, 6… where each word
would have 2 bytes of information. Similarly, if we have a machine with a word length of 32 bit then the
successive words are located at the addresses 0, 4, 8, 12… where each word would have 4 bytes of
information and it could store or retrieve 4 bytes of instruction or data in a single and basic operation.
The big-endian and little-endian are two methods of assigning byte addresses across the words in the
memory. In the big-endian assignment, the lower byte addresses are used for the leftmost bytes of the
word. Observe the word 0 in the image below, the leftmost bytes of the word have lower byte addresses.
In the little-endian assignment, the lower byte addresses are used for the rightmost bytes of the word.
Observe the word 0 in the image below the rightmost bytes of word 0 has lower byte addresses .
The leftmost bytes of the word are termed as most significant bytes and the rightmost bytes of the words
are termed as least significant bytes.
Thus the big-endian and little-endian specify the ordering of bytes inside a word. Similarly, the bits must
be labeled inside the byte or a word and the most common way of labeling bits in a byte or word is as
shown in the figure below i.e. labeling the bits as b7, b6,…….,b1, b0 from left to write as we do in little-
endian assignment .
Memory Operations:
Random access memories must have two basic operations:
Write: writes a data into the specified location
Read: reads the data stored in the specified location
In machine language program, the two basic operations usually are called Store: write operation
Load: read operation
The Load operation transfers a copy of the contents of a specific memory location to the processor. The
memory contents remain unchanged
The Store operation transfers an item of information from the processor to a specific memory location,
destroying the former contents of that location
Assembler Directives In addition to providing a mechanism for representing instructions in a program, the
assembly language allows the programmer to specify other information needed to translate the source
program into the object program Suppose that the name SUM is used to represent the value 200. The fact
may be conveyed to the assembler program through a statement such as SUM EQU 200. This statement
does not denote an instruction that will be executed when the object program is run; it will not even appear
in the object program Such statements, called assembler directives (or commands)