0% found this document useful (0 votes)
14 views23 pages

COD Unit-2 (CH 3) (E-Next - In)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views23 pages

COD Unit-2 (CH 3) (E-Next - In)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

COD Unit-2

UNIT- 2

Memory Organization in Computer Architecture


 A memory unit is the collection of storage units or devices together.
 The memory unit stores the binary information in the form of bits.
 Generally, memory/storage is classified into 2 categories:
a. Volatile Memory: This loses its data, when power is switched off.
b. Non-Volatile Memory:This is a permanent storage and does not lose any data when
power is switched off.

Memory Hierarchy

 The total memory capacity of a computer can be visualized by hierarchy of components.


 The memory hierarchy system consists of all storage devices contained in a computer system
from the slow Auxiliary Memory to fast Main Memory and to smaller Cache memory.
A. AUXILIARY MEMORY(SECONDARY MEMORY) :
1. Auxiliary memory (also referred to as secondary storage) is the non-volatile memory
lowest-cost, highest-capacity, and slowest-access storage in a computer system.
2. It is where programs and data kept for long-term storage or when not in immediate use.
3. Auxiliary memory holds data for future use, and that retains information even the power
fails.
4. Auxiliary memory is much larger in size than main memory but is slower.

Khan S. Alam 1 https://E-next.in

https://E-next.in
COD Unit-2

5. It normally stores system programs, instruction and data files. It is also known as
secondary memory.
6. It can also be used as an overflow/virtual memory in case the main memory capacity has
been exceeded.
7. Secondary memories cannot be accessed directly by a processor. First the
data/information of auxiliary memory is transferred to the main memory and then that
information can be accessed by the CPU.
8. The secondary storage devices are:
a. Floppy Disks
b. Magnetic (Hard) Disk
c. Magnetic Tapes
d. Pen Drive
e. Optical Disk(CD,DVD)

Characteristics of Auxiliary Memory: Characteristics of Auxiliary Memory are following ,

 Non-volatile memory − Data is not lost when power is cut off.

 Reusable − The data stays in the secondary storage on permanent basis until it is not
overwritten or deleted by the user.

 Reliable − Data in secondary storage is safe because of high physical stability of


secondary storage device.

 Convenience − With the help of a computer software, authorized people can locate and
access the data quickly.

 Capacity − Secondary storage can store large volumes of data in sets of multiple disks.

 Cost − It is much lesser expensive to store data on a tape or disk than primary memory.
B. PRIMARY MEMORY(MAIN MEMORY):

1. The main memory occupies the central position because it is equipped to communicate
directly with the CPU and with auxiliary memory devices through Input/output processor
(I/O).
2. Primary memory is internal memory of the computer. It is also known as main memory
and Temporary memory .
3. Primary Memory holds the data and instruction on which computer is currently working.
4. Primary Memory is nature volatile. It means when power is switched off it lost all data.

Khan S. Alam 2 https://E-next.in

https://E-next.in
COD Unit-2

Types of Primary Memory– Primary memory is generally of two types.

1. RAM
2. ROM

1. RAM (Random Access Memory) – It stands for Random Access Memory.


 RAM is known as read /writes memory. It generally refereed as main memory of
the computer system.
 It is a temporary memory.
 The information stored in this memory is lost as the power supply to the computer
is switched off.
 That’s why RAM is also called “Volatile Memory”

Types of RAM– RAM is also of two types:

a) Static RAM-
 Static RAM also known as SRAM ,retain stored information as long as the
power supply is ON.
 SRAM are of higher coast and consume more power .
 They have higher speed than Dynamic RAM
b) Dynamic RAM–
 Dynamic RAM also known as DRAM, its stored information in a very short
time (a few milliseconds) even though the power supply is ON.
 The Dynamic RAM are cheaper and moderate speed and also they consume
less power.

2. ROM (Read Only Memory) –


 It stands for Read Only Memory.ROM is a Permanent Type memory.
 Its content are not lost when power supply is switched off.
 Content of ROM is decided by the computer manufacturer and permanently
stored at the time of manufacturing.
 ROM cannot be overwritten by the computer. It is also called “Non-Volatile
Memory”.

Type of ROM: ROM memory is three types names are following-

a. PROM(Programmable Read Only Memory)-


 PROM chip is programmable ROM.
 it is PROM chips to write data once and read many.
 once chip has been programmed ,the recorded information cannot be
changed.
 PROM is also nonvolatile memory.
b. EPROM (Erasable Programmable Read Only Memory)-
 EPROM chip can be programmed time and again by erasing the information
stored earlier in it.
 Information stored in EPROM exposing the chip for some time ultraviolet
light .

Khan S. Alam 3 https://E-next.in

https://E-next.in
COD Unit-2

c. EEPROM (Electrically Erasable Programmable Read Only Memory)-


 The EEPROM is programmed and erased by special electrical waves in
millisecond.
 A single byte of a data or the entire contents of device can be erased.

Differences between Primary and Secondary Memory

S.N. Primary memory Secondary memory

1 Primary memory is temporary Secondary memory is permanent

Primary memory is directly accessible by Secondary memory is not directly accessible by


2
Processor/CPU CPU

Nature of Parts of Primary memory varies.


3 It’s always Non-volatile in nature
RAM- volatile in nature. ROM- Non-volatile

Primary memory devices are more expensive Secondary memory devices are less expensive
4
than secondary storage devices when compare to primary memory devices

The memory devices used for primary memory The secondary memory devices are magnetic
5
are semiconductor memories and optical memories

Primary memory is also known as Main Secondary memory is also known as External
6
memory or Internal memory memory or Auxiliary memory

Examples: RAM, ROM, Cache memory, Examples: Hard Disk, Floppy Disk, Magnetic
7
PROM, EPROM, Registers etc Tapes etc

C. CACHE MEMORY:
 A Cache (Pronounced as “cash”) is a small and very fast temporary storage memory.
 It is designed to speed up the transfer of data and instructions. It is located inside or close
to the CPU chip.
 It is faster than RAM and the data/instructions that are most recently or most frequently
used by CPU are stored in cache.
 The data and instructions are retrieved from RAM when CPU uses them for the first time.
 A copy of that data or instructions is stored in cache. The next time the CPU needs that
data or instructions, it first looks in cache.
 If the required data is found there, it is retrieved from cache memory instead of main
memory. It speeds up the working of CPU.

Khan S. Alam 4 https://E-next.in

https://E-next.in
COD Unit-2

D. REGISTER MEMORY:
 In a computer, the Memory Address Register (MAR) is the CPU register that either
stores the memory address from which data will be fetched from the CPU, or the address
to which data will be sent and stored.
 In general, MAR is a parallel loadregister that contains the next memory address to be
manipulated.

WORD SIZE:

 Word is the collection of several bytes.


 Word size is completely depend on the
 In computing, word size refers to the maximum number of bits that a CPU can process at
a time.
 A word is a fixed-sized piece of data which is dictated by the processor hardware
architecture; fixed in a sense that it is the maximum size that the processor is always
using.

 Originally, "word" meant 16 bits, as that was the maximum possible value at the time.
 Word size could be as low as 4 bits or as high as 64 bits, depending on what a particular
processor can handle.
 Word size is used for a number of concepts, all relating to processing. It is used in any of
the following:
i. Addresses –
The address must be able to represent the full range possible, so it uses a
full word or a multiple of it.
ii. Fixed-point numbers —
Integers are available in different sizes, but usually it takes the size of the
full word supported by the processor.
iii. Floating-point numbers —
Holders for floating-point numbers typically use the full word size length
or multiples of it.
iv. Registers —
The size of the register depends on the kind of register and what its
purpose is, but a general-purpose register usually uses the maximum word
size capability of the processor.
v. Instructions —
Instruction sets for processors are often coded in full word size.

BIG AND LITTLE ENDIAN:

1. This is the ordering of words.


2. Little and big endian are two ways of storing multi-byte data-types (int, float, etc).
3. Big-endian and little-endian are terms that describe the order in which a sequence
of bytes are stored in computer memory

Khan S. Alam 5 https://E-next.in

https://E-next.in
COD Unit-2

a) BIG ENDIAN:
 When the byte address are stored from left to right side then it is known as Big Endian.
 In big endian machines, first byte of binary representation of the multi-byte
data-type is stored first.
 Big-endian is an order in which the "big end" (most significant value in the
sequence) is stored first (at the lowest storage address).
 In Big-Endian, Most-Significant-Byte (MSB) is stored at lowest address
 For example, in a big-endian computer, the two bytes required for
the hexadecimal number 4F52 would be stored as 4F52 in storage (if 4F is
stored at storage address 1000, for example, 52 will be at address 1001).

b) LITTLE ENDIAN:
 When the byte address is stored from right to left it is called ad Little endian.
 In little endian machines, last byte of binary representation of the multi-byte
data-type is stored first.
 Little-endian is an order in which the "little end" (least significant value in the
sequence) is stored first.
 In Little-Endian, Least-Significant-Byte (LSB) is stored at lowest address.
 In a little-endian system, it would be stored as 524F (52 at address 1000, 4F at
1001).

Khan S. Alam 6 https://E-next.in

https://E-next.in
COD Unit-2

INSTRUCTION SET FOR RISC AND CISC

INSTRUCTION SET:

 Hardware designers invent numerous technologies & tools to implement the desired
architecture in order to fulfill these needs.
 Hardware architecture may be implemented to be either hardware specific or software
specific, but according to the application both are used in the required quantity.
 As far as the processor hardware is concerned, there are 2 types of concepts to implement
the processor hardware architecture.
 First one is RISC and other is CISC.

CISC (COMPLEX INSTRUCTION SET COMPUTING) ARCHITECTURE

 The CISC approach attempts to minimize the number of instructions per program,
sacrificing the number of cycles per instruction.
 Computers based on the CISC architecture are designed to decrease the memory cost.
 Because, the large programs need more storage, thus increasing the memory cost and
large memory becomes more expensive.
 To solve these problems, the number of instructions per program can be reduced by
embedding the number of operations in a single instruction, thereby making the
instructions more complex.

 MUL loads two values from the memory into separate registers in CISC.
 CISC uses minimum possible instructions by implementing hardware and executes
operations.

Khan S. Alam 7 https://E-next.in

https://E-next.in
COD Unit-2

 Instruction Set Architecture is a medium to permit communication between the


programmer and the hardware.
 Data execution part, copying of data, deleting or editing is the user commands used in the
microprocessor and with this microprocessor the Instruction set architecture is operated.
 The main keywords used in the above Instruction Set Architecture are as below

CHARACTERISTICS OF CISC ARCHITECTURE

 Instruction-decoding logic will be Complex.


 One instruction is required to support multiple addressing modes.
 Less chip space is enough for general purpose registers for the instructions that are
operated directly on memory.
 Various CISC designs are set up two special registers for the stack pointer, handling
interrupts, etc.
 MUL is referred to as a “complex instruction” and requires the programmer for storing
functions.

RISC(REDUCED INSTRUCTION SET COMPUTING) ARCHITECTURE

 RISC (Reduced Instruction Set Computer) is used in portable devices due to its power
efficiency.
 For Example, Apple iPod and Nintendo DS. RISC is a type of microprocessor
architecture that uses highly-optimized set of instructions.
 RISC does the opposite, reducing the cycles per instruction at the cost of the number of
instructions per program Pipelining is one of the unique feature of RISC.
 It is performed by overlapping the execution of several instructions in a pipeline fashion.
It has a high performance advantage over CISC.

RISC processors take simple instructions and are executed within a clock cycle

Khan S. Alam 8 https://E-next.in

https://E-next.in
COD Unit-2

RISC ARCHITECTURE CHARACTERISTICS

 Simple Instructions are used in RISC architecture.


 RISC helps and supports few simple data types and synthesize complex data types.
 RISC utilizes simple addressing modes and fixed length instructions for pipelining.
 RISC permits any register to use in any context.
 One Cycle Execution Time
 The amount of work that a computer can perform is reduced by separating “LOAD” and
“STORE” instructions.
 RISC contains Large Number of Registers in order to prevent various number of
interactions with memory.
 In RISC, Pipelining is easy as the execution of all instructions will be done in a uniform
interval of time i.e. one click.
 In RISC, more RAM is required to store assembly level instructions.
 Reduced instructions need a less number of transistors in RISC.
 RISC uses Harvard memory model means it is Harvard Architecture.
 A compiler is used to perform the conversion operation means to convert a high-level
language statement into the code of its form.

RISC & CISC Comparison:

Comparison between CISC & RISC


The Advantages and Disadvantages of RISC and CISC

The Advantages of RISC architecture

 RISC(Reduced instruction set computing)architecture has a set of instructions, so high-


level language compilers can produce more efficient code
 It allows freedom of using the space on microprocessors because of its simplicity.
 Many RISC processors use the registers for passing arguments and holding the local
variables.

Khan S. Alam 9 https://E-next.in

https://E-next.in
COD Unit-2

 RISC functions use only a few parameters, and the RISC processors cannot use the call
instructions, and therefore, use a fixed length instruction which is easy to pipeline.
 The speed of the operation can be maximized and the execution time can be minimized.
Very less number of instructional formats, a few numbers of instructions and a few
addressing modes are needed.

The Disadvantages of RISC architecture

 Mostly, the performance of the RISC processors depends on the programmer or compiler
as the knowledge of the compiler plays a vital role while changing the CISC code to a
RISC code
 While rearranging the CISC code to a RISC code, termed as a code expansion, will
increase the size. And, the quality of this code expansion will again depend on the
compiler, and also on the machine’s instruction set.
 The first level cache of the RISC processors is also a disadvantage of the RISC, in which
these processors have large memory caches on the chip itself. For feeding the
instructions, they require very fast memory systems.

Advantages of CISC architecture

 Microprogramming is easy assembly language to implement, and less expensive than


hard wiring a control unit.
 The ease of microcoding new instructions allowed designers to make CISC machines
upwardly compatible:
 As each instruction became more accomplished, fewer instructions could be used to
implement a given task.

Disadvantages of CISC architecture

 The performance of the machine slows down due to the amount of clock time taken by
different instructions will be dissimilar
 Only 20% of the existing instructions is used in a typical programming event, even
though there are various specialized instructions in reality which are not even used
frequently.
 The conditional codes are set by the CISC instructions as a side effect of each instruction
which takes time for this setting – and, as the subsequent instruction changes the
condition code bits – so, the compiler has to examine the condition code bits before this
happens.

Addressing Modes:
 Addressing modes are the manner in the data is accessed.
 Depending upon the type of instruction applied, addressing modes are of various types
such as direct mode where straight data is accessed or indirect mode where the location
of the data is accessed.

Khan S. Alam 10 https://E-next.in

https://E-next.in
COD Unit-2

 The addressing modes in computer architecture actually define how an


operand is chosen to execute an instruction.
 It is the way that is used to identify the location of an operand which is
specified in an instruction.
 Whenever an instruction executes, it requires operands to be operated on.
 An instruction field consisting of opcode and operand. Where
operand means the data and opcode means the instruction itself.
 In case of operations like addition or subtraction, they require two data. So,
they are called binary instruction. On the other hand, the increment or
decrement operations need only one data and are so called unary
instruction.
 The various addressing modes in computer architecture can be classified as
below.
 We have some other addressing modes too, but these are the prime
addressing modes in computer architecture.

Addressing modes in computer architecture:


 Implicit
 Immediate
 Direct
 Indirect
 Register
 Register Indirect
1. Implicit addressing mode :
 The term implicit addressing mode means here we are not mentioning clearly in
details that from where the instruction can get the operand. But by default, the
instruction itself knows from where it is supposed to access the operand.
 It is 1 byte instruction
 For example, CMA stands for complement accumulator. The meaning of
the CMA instruction is whatever the value present in the accumulator will be
replaced by its 1’s complement.
 In this instruction CMA or along with this instruction, we are not mentioning any
operand. So here it knows that the operand has to be accessed from the
accumulator implicitly. This is known as implicit addressing modes.
2. Immediate addressing mode :
 In the Immediate addressing mode the operand value is always present into the
instructions.
 The data is either 8 bit or 16 bit
 It is 2 byte addressing mode 1st byte for opcode and 2nd byte for operand.
 In the immediate addressing mode, the instruction contains two fields. One for
the opcode and another field contains the operand itself.
 That means in this addressing mode, there is no need to go anywhere to access the
operand because of the instruction itself containing the operand.

Khan S. Alam 11 https://E-next.in

https://E-next.in
COD Unit-2

 This is known as immediate addressing mode.

 Example mov R1, 10

3. Direct addressing mode :


 It is 16 -24bit addressing mode . It have 3 byte of and addressing mode.
 1st byte for the opcode, 2nd byte for lower operand, 3rd byte for the higher operand

 In the direct addressing mode, the instruction will have the two parts. One part will
contain the opcode and another one will contain the address of the memory
location at where the operand can be found.
 Here A is the address of the operand. That means at the Ath location in the memory,
the operand can be found.

Example : Add R1, 1001 (here 1001 is effective address of operand)


4. Indirect addressing mode :
 Indirect addressing mode contains the opcode and address field.
 But unlike direct addressing mode, it doesn’t contain the address of the operand
but contains the address of a memory location in which the actual address of the
operand can be found.

Khan S. Alam 12 https://E-next.in

https://E-next.in
COD Unit-2

Here A contains the address of the location B in memory and B contains the actual
address of the operand in memory.

5. Register addressing mode:


 In case of register addressing mode, the instruction will have the opcode and
a register number.
 It is 1 Byte long .
 Only opcode is present in the instructions.
 In this type of addressing mode the data is transferred from the register.
 Depending upon the register number, one of the registers will be selected from the
available sets of registers by default automatically.
 The unique identification of the register can be done by the register number which
is mentioned in the instruction. In that register, the operand can be found.

Khan S. Alam 13 https://E-next.in

https://E-next.in
COD Unit-2

 Advantage:
i) Shorter instructions and faster instruction featch.
ii) Faster memory access to the operand.
 Disadvantages:
i) Very limited address space
ii) Using multiple registers help performance but it complicates the
instructions.

6. Register indirect addressing mode :


 In the register indirect addressing mode, the instruction will contain the opcode as
well as a register number.
 Depending upon the register number mentioned in the instruction, the
corresponding register will be accessed from the set of registers.
 But here the register doesn’t contain the operand but will contain the address of
the operand in the memory at where the operand can be found.

 Suppose in memory, the operand is in the Ath location. Now, this address A will be
stored in the register and the register number say R will be mentioned in the
instruction.
 This is called register addressing mode.

MACHINE LANGUAGE

 Machine code, also known as machine language, is the elemental language of computers.
 It is read by the computer's central processing unit (CPU), is composed of
digital binarynumbers and looks like a very long sequence of zeros and ones.

Khan S. Alam 14 https://E-next.in

https://E-next.in
COD Unit-2

 Ultimately, the source code of every human-readable programming language must be


translated to machine language by a compiler or an interpreter, because binary code is the
only language that computer hardware can understand.
 Each CPU has its own specific machine language. The processor reads and handles
instructions, which tell the CPU to perform a simple task.
 Instructions are comprised of a certain number of bits.
 If instructions for a particular processor are 8 bits, for example, the first 4 bits part (the
opcode) tells the computer what to do and the second 4 bits (the operand) tells the
computer what data to use.

01001000 01100101 01101100 01101100 01101111 00100001

 Depending upon the processor, a computer's instruction sets may all be the same length,
or they may vary, depending upon the specific instruction.
 The architecture of the particular processor determines how instructions are patterned.
 The execution of instructions is controlled by firmware or the CPU's internal wiring.
 Human programmers rarely, if ever, deal directly with machine code anymore.
 If developers are debugging a program at a low level, they might use a printout that
shows the program in its machine code form.
 The printout, which is called a dump, is very difficult and to work with a tool called a
dump.
 Utility programs used to create dumps will often represent four bits by a
single hexadecimal to make the machine code easier to read and contain other
information about the computer's operation, such as the address of the instruction that
was being executed at the time the dump was initiated.

 Below is an example of machine language (binary) for the text "Hello


World".
01001000 01100101 01101100 01101100 01101111 00100000 01010111
01101111 01110010 01101100 01100100

 Below is another example of machine language (non-binary), which


will print the letter "A" 1000 times to the computer screen.
169 1 160 0 153 0 128 153 0 129 153 130 153 0 131 200 208 241 96

Khan S. Alam 15 https://E-next.in

https://E-next.in
COD Unit-2

ASSEMBLY LANGUAGE

What is Assembly Language?


 An assembly language is a low-level programming language designed for a specific type
of processor.
 It may be produced by compiling source code from a high-level programming language
(such as C/C++) but can also be written from scratch.
 Assembly code can be converted to machine code using an assembler.
 Since most compilers convert source codedirectly to machine code, software developers
often create programs without using assembly language.
 However, in some cases, assembly code can be used to fine-tune a program.
 For example, a programmer may write a specific process in assembly language to make
sure it functions as efficiently as possible.
 While assembly languages differ between processor architectures, they often include
similar instructions and operators.
 Below are some examples of instructions supported by x86 processors.
o MOV - move data from one location to another
o ADD - add two values
o SUB - subtract a value from another value
o PUSH - push data onto a stack
o POP - pop data from a stack
o JMP - jump to another location
o INT - interrupt a process

 Each personal computer has a microprocessor that manages the computer's arithmetical,
logical, and control activities.
 Each family of processors has its own set of instructions for handling various operations
such as getting input from keyboard, displaying information on screen and performing
various other jobs.
 These set of instructions are called 'machine language instructions'.
 A processor understands only machine language instructions, which are strings of 1's and
0's.
 However, machine language is too obscure and complex for using in software
development.
 So, the low-level assembly language is designed for a specific family of processors that
represents various instructions in symbolic code and a more understandable form.

Khan S. Alam 16 https://E-next.in

https://E-next.in
COD Unit-2

Advantages of Assembly Language


Having an understanding of assembly language makes one aware of −

 How programs interface with OS, processor, and BIOS;


 How data is represented in memory and other external devices;
 How the processor accesses and executes instruction;
 How instructions access and process data;
 How a program accesses external devices.
Other advantages of using assembly language are −

 It requires less memory and execution time;

 It allows hardware-specific complex jobs in an easier way;

 It is suitable for time-critical jobs;

 It is most suitable for writing interrupt service routines and other memory resident
programs.
Types of Assembly Languages
Assembly language closely tied to processor architecture. At least four main types:
 CISC: Complex Instruction-Set Computer.
 RISC: Reduced Instruction-Set Computer.
 DSP: Digital Signal Processor.
 VLIW: Very Long Instruction Word.

ASSEMBLER
 An assembler is a program that converts assembly language into machine code. It takes
the basic commands and operations from assembly code and converts them
into binary code that can be recognized by a specific type of processor.
 Assemblers are similar to compilers in that they produce executable code.
 However, assemblers are more simplistic since they only convert low-level code
(assembly language) to machine code.
 Since each assembly language is designed for a specific processor, assembling a program
is performed using a simple one-to-one mapping from assembly code to machine code.
 Compilers, on the other hand, must convert generic high-level source code into machine
code for a specific processor.
 Most programs are written in high-level programming languages and are compiled
directly to machine code using a compiler.

Khan S. Alam 17 https://E-next.in

https://E-next.in
COD Unit-2

 However, in some cases, assembly code may be used to customize functions and ensure
they perform in a specific way.
 Therefore, IDEs often include assemblers so they can build programs from both high and
low-level languages.

INSTRUCTIONS:

 An instruction is an order given to a computer processor by a computer program.


 At the lowest level, each instruction is a sequence of 0s and 1s that describes a physical
operation the computer is to perform (such as "Add") and, depending on the particular
instruction type, the specification of special storage areas called registers that may
contain data to be used in carrying out the instruction, or the location in computer
memory of data.
 In a computer's assembler language, each language statement generally corresponds to a
single processor instruction.
 In high-level languages, a language statement generally results (after program
compilation) in multiple processor instructions.
 In assembler language, a macro instruction is one that, during processing by the
assembler program, expands to become multiple instructions (based on a previously
coded macro definition).

Types Of Instruction:

1. Arithmetic Instructions

Arithmetic Instructions are the instructions which perform basic arithmetic operations such as
addition, subtraction and a few more. In 8085 microprocessor, the destination operand is
generally the accumulator. In 8085 microprocessor, the destination operand is generally the
accumulator.

Following is the table showing the list of arithmetic instructions:

Opcode Operand Explanation Example


ADD R A=A+R ADD B
ADD M A = A + Mc ADD 2050
ADI 8-bit data A = A + 8-bit data ADD 50
ADC R A = A + R + prev. carry ADC B
ADC M A = A + Mc + prev. carry ADC 2050
ACI 8-bit data A = A + 8-bit data + prev. carry ACI 50
SUB R A=A–R SUB B
SUB M A = A – Mc SUB 2050
SUI 8-bit data A = A – 8-bit data SUI 50

Khan S. Alam 18 https://E-next.in

https://E-next.in
COD Unit-2

Opcode Operand Explanation Example


SBB R A = A – R – prev. carry SBB B
SBB M A = A – Mc -prev. carry SBB 2050
SBI 8-bit data A = A – 8-bit data – prev. carry SBI 50
INR R R=R+1 INR B
INR M M = Mc + 1 INR 2050
INX r.p. r.p. = r.p. + 1 INX H
DCR R R=R–1 DCR B
DCR M M = Mc – 1 DCR 2050
DCX r.p. r.p. = r.p. – 1 DCX H
DAD r.p. HL = HL + r.p. DAD H

2. Logic Instruction: The processor instruction set provides the instructions AND, OR, XOR,
TEST, and NOT Boolean logic, which tests, sets, and clears the bits according to the need of
the program.

The format for these instructions –

Sr.No. Instruction Format


1 AND AND operand1, operand2
2 OR OR operand1, operand2
3 XOR XOR operand1, operand2
4 TEST TEST operand1, operand2
5 NOT NOT operand1

The AND Instruction


The AND instruction is used for supporting logical expressions by performing bitwise AND
operation. The bitwise AND operation returns 1, if the matching bits from both the operands are
1, otherwise it returns 0. For example −

Operand1: 0101
Operand2: 0011
----------------------------
After AND -> Operand1: 0001

The OR Instruction

Khan S. Alam 19 https://E-next.in

https://E-next.in
COD Unit-2

The OR instruction is used for supporting logical expression by performing bitwise OR


operation. The bitwise OR operator returns 1, if the matching bits from either or both operands
are one. It returns 0, if both the bits are zero.

For example,

Operand1: 0101
Operand2: 0011
----------------------------
After OR -> Operand1: 0111

The XOR Instruction


 The XOR instruction implements the bitwise XOR operation. The XOR operation sets
the resultant bit to 1, if and only if the bits from the operands are different.
 If the bits from the operands are same (both 0 or both 1), the resultant bit is cleared to 0.

For example,

Operand1: 0101
Operand2: 0011
----------------------------
After XOR -> Operand1: 0110

XORing an operand with itself changes the operand to 0. This is used to clear a register.

XOR EAX, EAX

The TEST Instruction


 The TEST instruction works same as the AND operation, but unlike AND instruction, it
does not change the first operand.
 So, if we need to check whether a number in a register is even or odd, we can also do this
using the TEST instruction without changing the original number.

Example: TEST AL, 01H


JZ EVEN_NUMBER

The NOT Instruction


 The NOT instruction implements the bitwise NOT operation. NOT operation reverses the
bits in an operand. The operand could be either in a register or in the memory.

For example,

Operand1: 0101 0011


After NOT -> Operand1: 1010 1100

Khan S. Alam 20 https://E-next.in

https://E-next.in
COD Unit-2

Shift Instruction:
 In computer science, a logical shift is a bitwise operation that shifts all the bits of its
operand.
 The two base variants are the logical left shift and the logical right shift.
 This is further modulated by the number of bit positions a given value shall be shifted,
such as shift left by 1 or shift right by n.
 Unlike an arithmetic shift, a logical shift does not preserve a number's sign bit or
distinguish a number's exponent from its significand (mantissa); every bit in the operand
is simply moved a given number of bit positions, and the vacant bit-positions are filled,
usually with zeros, and possibly ones (contrast with a circular shift).
 A logical shift is often used when its operand is being treated as a sequence of bits
instead of as a number.
 Logical shifts can be useful as efficient ways to perform multiplication or division of
unsigned integers by powers of two.
 Shifting left by n bits on a signed or unsigned binary number has the effect of multiplying
it by 2n. Shifting right by n bits on an unsigned binary number has the effect of dividing it
by 2n (rounding towards 0).
 Logical right shift differs from arithmetic right shift. Thus, many languages have
different operators for them.
 For example, in Java and JavaScript, the logical right shift operator is >>>, but the
arithmetic right shift operator is >>.
 (Java has only one left shift operator (<<), because left shift via logic and arithmetic have
the same effect.)

Example
If the bit sequence 0001 0111 (decimal 23) is logically shifted by one bit position, then:

Shift left yields: 0010 1110 (decimal 46)

Logical right shift one bit

Khan S. Alam 21 https://E-next.in

https://E-next.in
COD Unit-2

Shift right yields: 0000 1011 (decimal 11)

Logical right shift one bit

INSTRUCTION SET:

 The instruction set, also called instruction set architecture (ISA), is part of a computer
that pertains to programming, which is basically machine language.
 The instruction set provides commands to the processor, to tell it what it needs to do.
 The instruction set consists of addressing modes, instructions, native data types, registers,
memory architecture, interrupt, and exception handling, and external I/O.
 An example of an instruction set is the x86 instruction set, which is common to find on
computers today.
 Different computer processors can use almost the same instruction set while still having
very different internal design.

Examples of instruction set


 ADD - Add two numbers together.
 COMPARE - Compare numbers.
 IN - Input information from a device, e.g., keyboard.
 JUMP - Jump to designated RAM address.
 JUMP IF - Conditional statement that jumps to a designated RAM address.
 LOAD - Load information from RAM to the CPU.
 OUT - Output information to device, e.g., monitor.
 STORE - Store information to RAM.

Instruction Cycle;

The instruction set, also called instruction set architecture (ISA), is part of a computer that
pertains to programming, which is basically machine language. The instruction set provides
commands to the processor, to tell it what it needs to do. The instruction set consists of
addressing modes, instructions, native data types, registers, memory architecture, interrupt, and
exception handling, and external I/O.

Khan S. Alam 22 https://E-next.in

https://E-next.in
COD Unit-2

An example of an instruction set is the x86 instruction set, which is common to find on
computers today. Different computer processors can use almost the same instruction set while
still having very different internal design. Both the Intel Pentium and AMD Athlon processors
use nearly the same x86 instruction set. An instruction set can be built into the hardware of the
processor, or it can be emulated in software, using an interpreter. The hardware design is more
efficient and faster for running programs than the emulated software version.

Examples of instruction set


 ADD - Add two numbers together.
 COMPARE - Compare numbers.
 IN - Input information from a device, e.g., keyboard.
 JUMP - Jump to designated RAM address.
 JUMP IF - Conditional statement that jumps to a designated RAM address.
 LOAD - Load information from RAM to the CPU.
 OUT - Output information to device, e.g., monitor.
 STORE - Store information to RAM.

Khan S. Alam 23 https://E-next.in

https://E-next.in

You might also like