0% found this document useful (0 votes)
13 views

CO Unit1 Part2

The document discusses different number systems used in computers including binary, octal, decimal, and hexadecimal number systems. It then covers binary arithmetic operations like addition, subtraction, multiplication, and division. Finally, it discusses addressing modes that specify how operands in instructions are addressed in memory including implied, immediate, direct, indirect, register direct, register indirect, indexed, base register, auto-increment, and auto-decrement addressing modes.

Uploaded by

ispclx
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

CO Unit1 Part2

The document discusses different number systems used in computers including binary, octal, decimal, and hexadecimal number systems. It then covers binary arithmetic operations like addition, subtraction, multiplication, and division. Finally, it discusses addressing modes that specify how operands in instructions are addressed in memory including implied, immediate, direct, indirect, register direct, register indirect, indexed, base register, auto-increment, and auto-decrement addressing modes.

Uploaded by

ispclx
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Number Systems:

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.

The Number Systems used in computers are:

o Binary number system


o Octal number system
o Decimal number system
o Hexadecimal number system

Binary number system

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.

Octal 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.

Decimal number system

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.

Hexadecimal number system

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.

In fourth case, a binary addition is creating a sum of (1 + 1 = 10) i.e. 0 is


written in the given column and a carry of 1 over to the next column.

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

Signed binary numbers:


For signed binary numbers the most significant bit (MSB) is used as the sign bit. If the sign bit is “0”, this
means the number is positive in value. If the sign bit is “1”, then the number is negative in value. The
remaining bits in the number are used to represent the magnitude of the binary number in the usual
unsigned binary number format way.
Then we can see that the Sign-and-Magnitude (SM) notation stores positive and negative values by
dividing the “n” total bits into two parts: 1 bit for the sign and n–1 bits for the value which is a pure binary
number. For example, the decimal number 53 can be expressed as an 8-bit signed binary number as
follows.

Positive Signed Binary Numbers

Negative Signed Binary Numbers


Addressing Modes:
The term addressing modes refers to the way in which the operand of an instruction is specified.
The addressing mode specifies a rule for interpreting or modifying the address field of the
instruction before the operand is actually executed.

1. Implied Addressing Mode-


In this addressing mode,
 The definition of the instruction itself specifies the operands implicitly.
 It is also called as implicit addressing mode.
Examples-

The instruction “Complement Accumulator” is an implied mode instruction.


 In a stack organized computer, Zero Address Instructions are implied mode instructions.
(since operands are always implied to be present on the top of the stack)
2. Immediate Addressing Mode-
In this addressing mode,
 The operand is specified in the instruction explicitly.
 Instead of address field, an operand field is present that contains the operand.
Examples-
ADD 10 will increment the value stored in the accumulator by 10.
 MOV R #20 initializes register R to a constant value 20.
3. Direct Addressing Mode-
In this addressing mode,
 The address field of the instruction contains the effective address of the operand.
 Only one reference to memory is required to fetch the operand.
 It is also called as absolute addressing mode.

Example-
ADD X will increment the value stored in the accumulator by the value stored at memory location X.
AC ← AC + [X]

5. Indirect Addressing Mode-


In this addressing mode,
 The address field of the instruction specifies the address of memory location that contains the
effective address of the operand.
 Two references to memory are required to fetch the operand.

Example-
ADD X will increment the value stored in the accumulator by the value stored at memory location
specified by X.
AC ← AC + [[X]]

6. Register Direct Addressing Mode-


In this addressing mode,
 The operand is contained in a register set.
 The address field of the instruction refers to a CPU register that contains the operand.
 No reference to memory is required to fetch the operand.

Example-
ADD R will increment the value stored in the accumulator by the content of register R.
AC ← AC + [R]

7. Register Indirect Addressing Mode-


In this addressing mode,
 The address field of the instruction refers to a CPU register that contains the effective address of
the operand.
 Only one reference to memory is required to fetch the operand.

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.

ffective Address= Content of Index Register + 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.

Effective Address= Content of Base Register + Address part of the instruction

10. Auto-Increment Addressing Mode-

 This addressing mode is a special case of Register Indirect Addressing Mode where-

Effective Address of the Operand= Content of Register

In this addressing mode,


 After accessing the operand, the content of the register is automatically incremented by step size
‘d’.
 Step size ‘d’ depends on the size of operand accessed.
 Only one reference to memory is required to fetch the operand.
Example-

Assume operand size = 2 bytes.


Here,
 After fetching the operand 6B, the instruction register RAUTO will be automatically incremented by 2.
 Then, updated value of RAUTO will be 3300 + 2 = 3302.
 At memory address 3302, the next operand will be found.
11. Auto-Decrement Addressing Mode-
This addressing mode is again a special case of Register Indirect Addressing Mode where-

Effective Address of the Operand = Content of Register – Step Size


In this addressing mode,
 First, the content of the register is decremented by step size ‘d’.
 Step size ‘d’ depends on the size of operand accessed.
 After decrementing, the operand is read.
 Only one reference to memory is required to fetch the operand.
Example-
Assume operand size = 2 bytes.
Here,
 First, the instruction register RAUTO will be decremented by 2.
 Then, updated value of RAUTO will be 3302 – 2 = 3300.
 At memory address 3300, the operand will be found.

Memory Locations and Addresses:


Memory locations and addresses determine how the computer’s memory is organized so that the user can
efficiently store or retrieve information from the computer. The computer’s memory is made of a silicon
chip which has millions of storage cell, where each storage cell is capable to store a bit of information
which value is either 0 or 1.

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.

210 = 1024 = 1K (Kilobyte)


220 = 1,048,576 = 1M (Megabyte)
230 = 1073741824 = 1G (Gigabyte)
240 = 1.0995116e+12 = 1T (Terabyte)

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.

Big-Endian and Little-Endian Assignments in Byte Addresses

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

INSTRUCTIONS & INSTRUCTION SEQUENCING:


The tasks carried out by a computer program consist of a sequence of small steps, suchas adding two
numbers, testing for a particular condition, reading a character from the keyboard, or sending a character to
be displayed on a display screen.
A computer must have instructions capable of performing 4 types of operations:
1) Data transfers between the memory and the registers (MOV, PUSH, POP, XCHG).
2) Arithmetic and logic operations on data (ADD, SUB, MUL, DIV, AND, OR, NOT).
3) Program sequencing and control(CALL.RET, LOOP, INT).
4) I/0 transfers (IN, OUT).
REGISTER TRANSFER NOTATION (RTN)
Here we describe the transfer of information from one location in a computer to another. Possible locations
that may be involved in such transfers are memory locations, processor registers, or registers in the I/O
subsystem. Most of the time, we identify such locations symbolically with convenient names.
• The possible locations in which transfer of information occurs are:
1) Memory-location
2) Processor register &
3) Registers in I/O device.
BASIC INSTRUCTION TYPES:

INSTRUCTION EXECUTION & STRAIGHT LINE SEQUENCING


• The program is executed as follows:
1) Initially, the address of the first instruction is loaded into PC
2) Then, the processor control circuits use the information in the PC to fetch and execute instructions, one at
a time, in the order of increasing addresses. This is called Straight-Line sequencing.
3) During the execution of each instruction, PC is incremented by 4 to point to next instruction.
• There are 2 phases for Instruction Execution:
1) Fetch Phase: The instruction is fetched from the memory-location and placed in the IR.
2) Execute Phase: The contents of IR is examined to determine which operation is to be performed. The
specified-operation is then performed by the processor.
Assembly Language:
A complete set of symbolic names and rules for their use constitute a programming language, generally
referred to as an assembly language. Programs written in an assembly language can be automatically
translated into a sequence of machine instructions by a program called an assembler .When the assembler
program is executed, it reads the user program, analyzes it, and then generates the desired machine
language program. The user program in its origin al alphanumeric text format is called a source program,
and the assembled machine language program is called an object program.

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)

You might also like