You are on page 1of 112

21EC1202

COMPUTER ORGANIZATION &


ARCHITECTURE
Computer Architecture, Computer system and its sub modules: State
Diagram various Architectures, Moore Machine, Mealy Machine, Von
Neumann architecture and hardware implementation of Arithmetic
and Logic Unit, Buses Types, Specifications of a computer, Concepts of
Machine level programming, Assembly level programming and High-
level programming. Various addressing modes and designing of an
Instruction set. Concepts of subroutine and subroutine call, use of
stack for handling subroutine call and return.
Mealy and Moore Models of Finite
State Machines
• A sequential circuit has inputs, outputs, and internal states.

• There are two models of sequential circuits: the Mealy model and

the Moore model.

• They differ only in the way the output is generated .

• In the Mealy model, the output is a function of both the present

state and the input .


Mealy and Moore machines

Mealy Machine

Moore Machine
Mealy Machine

The above state machine is Mealy type because the output “y” is a function of
present states and input “x”
Moore machine

The above state machine is Moore type because the output “y” is a function of
present states “A” and “B” only
Introduction to computer System and
its sub modules
• There are two basic types of electrical signals, namely, analog and

digital. The analog signals are continuous in nature and digital

signals are discrete in nature.

• The electronic device that works with continuous signals is known

as analog device and the electronic device that works with discrete

signals is known as digital device.

• We use ‘0’ to represent LOW and ‘1’ to represent HIGH.


Computer Organization & Architecture
Computer Organization
– physical aspects of computer systems.
– E.g., circuit design, control signals, memory types.
– How does a computer work?
Computer Architecture
– Logical aspects of system as seen by the programmer.
– E.g., instruction sets, instruction formats, data types, addressing
modes.
– How do I design a computer?
Computer Level Hierarchy
Computer Level Hierarchy

• Level 6: The User Level


– Program execution and user interface level.
– The level with which we are most familiar.

• Level 5: High-Level Language Level


– The level with which we interact when we write programs
in languages such as C, Pascal, Lisp, and Java.
Computer Level Hierarchy

• Level 4: Assembly Language Level


– Acts upon assembly language produced from Level 5, as
well as instructions programmed directly at this level.
• Level 3: System Software Level
– Controls executing processes on the system.
– Protects system resources.
– Assembly language instructions often pass through Level 3
without modification.
Computer Level Hierarchy

• Level 2: Machine Level


– Also known as the Instruction Set Architecture (ISA) Level.
– Consists of instructions that are particular to the
architecture of the machine.
– Programs written in machine language need no compilers,
interpreters, or assemblers.
Computer Level Hierarchy

• Level 1: Control Level


– A control unit decodes and executes instructions and
moves data through the system.
– Control units can be microprogrammed or hardwired.
– A microprogram is a program written in a low-level
language that is implemented by the hardware.
– Hardwired control units consist of hardware that directly
executes machine instructions.
Computer Level Hierarchy

• Level 0: Digital Logic Level


– This level is where we find digital circuits (the chips).
– Digital circuits consist of gates and wires.
– These components implement the mathematical logic of all
other levels.
Designing Computers
• All computers more or less based on the same basic design, the Von
Neumann Architecture
The Von Neumann Architecture
Model for designing and building computers, based on the following
three characteristics:
1) The computer consists of four main sub-systems:
– Memory
– ALU (Arithmetic/Logic Unit)
– Control Unit
– Input / Output System (I/O)

2) Program is stored in memory during execution.


3) Program instructions are executed sequentially.
The Von Neumann Architecture

Processor (CPU)

Memory Input-Output
Control Unit

ALU
Store Data & Program Communicate with
"outside world", e.g.
Execute program • Screen
• Keyboard
• Storage devices
Do arithmetic/logic operations
• ...
requested by program
Operations on Memory
• Fetch (address):
• Fetch a copy of the content of memory cell with the specified address.
• Non-destructive, copies value in memory cell.

• Store (address, value):


• Store the specified value into the memory cell specified by address.
• Destructive, overwrites the previous value of the memory cell.

• The memory system is interfaced via:


• Memory Address Register (MAR)
• Memory Data Register (MDR)
• Fetch/Store signal
Structure of the Memory Subsystem
• Fetch(address)
– Load address into MAR.
– Decode the address in MAR.
– Copy the content of memory cell
with specified address into MDR.

• Store(address, value)
– Load the address into MAR.
– Load the value into MDR.
– Decode the address in MAR
– Copy the content of MDR into
memory cell with the specified
address.
Von Neumann
Architecture
Input / Output Subsystem
• Handles devices that allow the computer system to:
1. Communicate and interact with the outside world
– Screen, keyboard, printer, ...

2. Store information (mass-storage)


– Hard-drives, floppies, CD, tapes, …

• Mass-Storage Device Access Methods:


1. Direct Access Storage Devices (DASDs)
– Hard-drives, floppy-disks, CD-ROMs, ...

2. Sequential Access Storage Devices (SASDs)


– Tapes (for example, used as backup devices)
Structure of the I/O Subsystem
The ALU Subsystem
• The ALU (Arithmetic/Logic Unit) performs
– mathematical operations (+, -, x, /, …)
– logic operations (=, <, >, and, or, not, ...)
• In today's computers integrated into the CPU
• Consists of:
– Circuits to do the arithmetic/logic operations.
– Registers (fast storage units) to store intermediate
computational results.
– Bus that connects the two.
Structure of the ALU
• Registers:
– Very fast local memory cells, that store
operands of operations and
intermediate results.
– CCR (condition code register), a special
purpose register that stores the result
of <, = , > operations
• ALU circuitry:
– Contains an array of circuits to do
mathematical/logic operations.
• Bus:
– Data path interconnecting the registers
to the ALU circuitry.
The Control Unit
• Program is stored in memory
– as machine language instructions, in binary
• The task of the control unit is to execute programs by repeatedly:
– Fetch from memory the next instruction to be executed.
– Decode it, that is, determine what is to be done.
– Execute it by issuing the appropriate signals to the ALU,
memory, and I/O subsystems.
– Continues until the HALT instruction
Structure of the Control Unit
• PC (Program Counter): stores the address of next instruction to
fetch
• IR (Instruction Register): stores the instruction fetched from
memory
• Instruction Decoder: Decodes instruction and activates necessary
circuitry
Basic Computer Model and different
units of Computer
• Central Processor Unit,
• Input Unit,
• Output Unit,
• Memory Unit
Components of Computer
• CPU – controls the operation of
the computer and performs its
data processing functions.

• Main Memory – stores data.


• I/O– moves data between the
computer and its external
environment.

• SystemInterconnection – some
mechanism that provides for
communication among CPU, main
memory, and I/O
ALU-Arithmetic & Logical Unit

• An arithmetic logic unit (ALU) is a combinational digital electronic

circuit that performs arithmetic and bitwise operations on integer

binary numbers.

• An ALU is a fundamental building block of many types of computing

circuits, including the central processing unit (CPU) of computers,

Floating Point Unit (FPUs), and graphics processing units (GPUs).


ALU-Arithmetic & Logical Unit
• Consider an ALU which can perform four arithmetic operations and
four logical operations To distinguish between arithmetic and
logical operation, we may use a signal line,
• 0 - in that signal, represents an arithmetic operation and
• 1 - in that signal, represents a logical operation.
ARITHMETIC LOGICAL
000 ADD 100 OR
001 SUB 101 AND
010 MULT 110 NOT
011 DIV 111 EX-OR
ALU-Arithmetic & Logical Unit
ALU-Arithmetic & Logical Unit
ALU-Arithmetic & Logical Unit

4 - Bit Full Adder


ALU-Arithmetic & Logical Unit
4 - Bit Full Subtractor
ALU-Arithmetic & Logical Unit
ALU-Arithmetic & Logical Unit
ALU-Arithmetic & Logical Unit
ALU-Arithmetic & Logical Unit
Memory Unit
1. RAM – Volatile Memory
2. ROM – Non volatile memory

Block Diagram of RAM Block Diagram of ROM


Memory Unit
• Main memory consists of a collection of storage locations, each
with a unique identifier, called an address. Data is transferred to
and from memory in groups of bits called words.
Memory Units
Memory Unit
Two main types of memory exist: RAM and ROM.

Random access memory (RAM)


1. Static RAM (SRAM)
2. Dynamic RAM (DRAM) – e.g., DDR SDRAM
– NAND-based Flash RAM

Read-only memory (ROM)


3. Programmable read-only memory (PROM).
4. Erasable programmable read-only memory (EPROM).
5. Electrically erasable programmable read-only memory (EEPROM).
Memory Hierarchy
Computer users need a lot of memory, especially memory that is very
fast and inexpensive. This demand is not always possible to satisfy—
very fast memory is usually not cheap. A compromise needs to be
made. The solution is hierarchical levels of memory.
Cache Memory
Cache memory is faster than main memory, but slower than the CPU
and its registers. Cache memory, which is normally small in size, is
placed between the CPU and main memory.
Control Unit
• To execute an instruction, the control unit of the CPU must

generate the required control signal in the proper sequence.

• To generate the control signal in proper sequence, a wide variety of

techniques exist. Most of these techniques, however, fall into one

of the two categories,

1. Hardwired Control

2. Microprogrammed Control
Programming language

A program is a set of instructions that the computer executes.

1. Machine language

2. Assembly language

3. High level language


Machine level programming
• Machine language is the language written as strings of binary 1’s &
0’s. it is the only language which a computer can understands
without a translation program.
• A machine language instruction has two parts.
1. Operation code: Which tells the computer what function to
perform
2. Operand: Which tells the computer on which the function is
operating & storing (Register or memory & so on)
Machine level programming

Disadvantages of Machine level programming

1. It is machine dependent i.e., it differs from computer to computer

2. It is difficult to program & write

3. It is prone to errors

4. It is difficult to modify
Assembly level programming

• It is a low level programming language that allows the user to write


a program using alphanumeric mnemonic codes, instead of numeric
codes for a set of instructions.
• It requires a translator known as Assembler to convert assembly
language into machine language.
• It assembles the machine language program in the main memory of
the computer and makes it ready for execution.
Assembly level programming

Advantages of Assembly level programming


1. It is easy to understand and use
2. It is easy to locate and correct errors
3. It is easier to modify

Disadvantages Assembly level programming


4. It is machine dependent
High level programming
• It is machine independent language. It enables the user to write
programs in a language which resembles English words and familiar
mathematical symbols.
• COBOL was the first high level language developed for business.
• Each statement in a high level language is a micro instruction which
is translated into several machine language instructions.
• A Compiler is a translator program which translates a high level
programming language into its equivalent machine language
programs.
High level programming
• Source code : It is the input or the programming instructor of a
procedural language. The compiler translates the source code into
machine level language which is known as object code. Object code
can be saved and executed as and when desired by the user.

Source Code Language translator program Object code

High level language Machine level language


High level programming
• Linker : A program used with a compiler to provide links to the
libraries needed for an executable program. It takes one or more
object code generated by a compiler and combines them into a
single executable program.
• Interpreter : It is a translator used for translating high level
language into the desired output. It takes one statement, translates
it into machine language instructions and then immediately
executes the result. Its output is the result of program execution.
High level programming
Advantages of High level programming
1. It is machine independent
2. It is easier to learn & use.
3. It is easier to maintain and gives few errors.

Disadvantages of High level programming


4. It lowers efficiency
5. It is less flexible
Subroutine and Subroutine call

• A routine or subroutine, also referred to as a function, procedure,


and subprogram, is a portion of code that may be called and
executed anywhere in a program.

• In different programming languages, a subroutine may be called


a procedure, a function, a routine, a method, or a subprogram. The
generic term callable unit is sometimes used
Subroutine and Subroutine call
• A subroutine is a reusable program module. A main program can
call or jump to the subroutine one or more times. The stack is used
in several ways when subroutines are called.

Important points to remember


1. How to write subroutines and call them from the main program.
2. Ways to pass parameters to and from subroutines.
3. The function of the stack and the stack pointer.
4. How to create and use software delays.
Subroutine and Subroutine call

• The stack is an area of memory identified by the programmer for


temporary storage of information.
• The stack is a LIFO structure.
– Last In First Out.
• The stack normally grows backwards into memory.
– In other words, the programmer defines the bottom of the stack
and the stack grows up into reducing address range.
Subroutine and Subroutine call
Subroutine and Subroutine call
• Given that the stack grows backwards into memory, it is customary
to place the bottom of the stack at the end of memory to keep it as
far away from user programs as possible.
• In the 8085, the stack is defined by setting the SP (Stack Pointer)
register.
– LXI SP, FFFFH
• This sets the Stack Pointer to location FFFFH (end of memory for
the 8085).
Subroutine and Subroutine call

• The Size of the stack is limited only by the available memory

• Information is saved on the stack by PUSHing it on.

• It is retrieved from the stack by POPing it off.

• The 8085 provides two instructions: PUSH and POP for storing

information on the stack and retrieving it back.

• Both PUSH and POP work with register pairs ONLY.


The PUSH Instruction
PUSH B (1 Byte Instruction)
1. Decrement SP
2. Copy the contents of register B to the memory location pointed to
by SP
3. Decrement SP
4. Copy the contents of register C to the memory location pointed to
by SP
The POP Instruction
POP D (1 Byte Instruction)
1. Copy the contents of the memory location pointed to by the SP to
register E
2. Increment SP
3. Copy the contents of the memory location pointed to by the SP to
register D
4. Increment SP
Subroutine Call
Types of CALLS
S.No. Type Description
1 Call by value Argument is evaluated and copy of value is passed
to subroutine
2 Call by reference Reference to argument, typically its address is
passed
3 Call by result Parameter value is copied back to argument on
return from the subroutine
4 Call by value-result Parameter value is copied back on entry to the
subroutine and again on return
5 Call by name Like a macro – replace the parameters with the
unevaluated argument expressions
6 Call by constant value Like call by value except that the parameter is
treated as a constant
Operation of the Stack

• During pushing, the stack operates in a “decrement then store”


style.
– The stack pointer is decremented first, then the information is placed on the
stack.

• During poping, the stack operates in a “use then increment” style.


– The information is retrieved from the top of the stack and then the pointer is
incremented.
– The SP pointer always points to “the top of the stack”.
Operation of the Stack
• The order of PUSHs and POPs must be opposite of each other in
order to retrieve information back into its original location.
PUSH B
PUSH D
...
POP D
POP B
• Reversing the order of the POP instructions will result in the
exchange of the contents of BC and DE.
Subroutines

The 8085 has two instructions for dealing with subroutines.

1. The CALL instruction is used to redirect program execution to the

subroutine.

2. The RET instruction is used to return the execution to the calling

routine.
The CALL Instruction
• CALL 4000H (3 byte instruction)
– When CALL instruction is fetched, the MP knows that the
next two Memory location contains 16bit subroutine address in the
memory.
The CALL Instruction
• MP Reads the subroutine address from the next two memory
location and stores the higher order 8bit of the address in the W
register and stores the lower order 8bit of the address in the Z
register
• Push the address of the instruction immediately following the CALL
onto the stack [Return address]
• Loads the program counter with the 16-bit address supplied with
the CALL instruction from WZ register.
The RET Instruction

• RET (1 byte instruction)


– Retrieve the return address from the top of the stack
– Load the program counter with the return address.
Subroutines
Things to be considered in Subroutine
• The CALL instruction places the return address at the two memory
locations immediately before where the Stack Pointer is pointing.
– You must set the SP correctly BEFORE using the CALL instruction.
• The RET instruction takes the contents of the two memory locations
at the top of the stack and uses these as the return address.
– Do not modify the stack pointer in a subroutine. You will loose
the return address.
Passing Data to a Subroutine
Data is passed to a subroutine through registers.

– Call by Reference:
• The data is stored in one of the registers by the calling program and
the subroutine uses the value from the register. The register values
get modified within the subroutine. Then these modifications will
be transferred back to the calling program upon returning from a
subroutine
Passing Data to a Subroutine

– Call by Value:
• The data is stored in one of the registers, but the subroutine first
PUSHES register values in the stack and after using the registers, it
POPS the previous values of the registers from the stack while
exiting the subroutine. i.e. the original values are restored before
execution returns to the calling program.
Cautions with PUSH and POP

• PUSH and POP should be used in opposite order.

• There has to be as many POP’s as there are PUSH’s.

– If not, the RET statement will pick up the wrong information

from the top of the stack and the program will fail.

• It is not advisable to place PUSH or POP inside a loop.


Conditional CALL and RTE Instructions
• The 8085 supports conditional CALL and conditional RTE
instructions.
• The same conditions used with conditional JUMP instructions can
be used.
– CC, call subroutine if Carry flag is set.
– CNC, call subroutine if Carry flag is not set
– RC, return from subroutine if Carry flag is set
– RNC, return from subroutine if Carry flag is not set
– Etc.
Various Addressing modes
The most common addressing techniques are:
• Immediate
• Direct
• Indirect
• Register
• Register Indirect
• Displacement
• Stack
Various Addressing modes
To explain the addressing modes, the following notations are used:

• A = contents of an address field in the instruction that refers to a


memory
• R = contents of an address field in the instruction that refers to a
register
• EA = actual (effective) address of the location containing the
referenced operand
• (X) = contents of location X
Immediate Addressing
• The simplest form of addressing is immediate addressing, in which
the operand is actually present in the instruction:
OPERAND   =   A
• The advantage of immediate addressing is that no memory
reference other than the instruction fetch is required to obtain the
operand. The disadvantage is that the size of the number is
restricted to the size of the address field, which, in most instruction
sets, is small compared with the world length.
Immediate Addressing
Direct Addressing
• A very simple form of addressing is direct addressing, in which the
address field contains the effective address of the operand:
EA   =   A
• It requires only one memory reference and no special calculation.
Indirect Addressing
• With direct addressing, the length of the address field is usually less
than the word length, thus limiting the address range. One solution
is to have the address field refer to the address of a word in
memory, which in turn contains a full-length address of the
operand. This is known as indirect addressing:
EA   =   (A)
Register Addressing
• Register addressing is similar to direct addressing. The only
difference is that the address field refers to a register rather than a
main memory address:
EA   =   R
• The advantages of register addressing are that only a small address
field is needed in the instruction and no memory reference is
required. The disadvantage of register addressing is that the
address space is very limited.
Register Addressing
Register Indirect Addressing
• Register indirect addressing is similar to indirect addressing, except
that the address field refers to a register instead of a memory
location.
• It requires only one memory reference and no special calculation.
EA   =   (R)
Displacement Addressing
• A very powerful mode of addressing combines the capabilities of
direct addressing and register indirect addressing, which is broadly
categorized as displacement addressing:
EA   =   A   +  (R)
• Displacement addressing requires that the instruction have two
address fields, at least one of which is explicit. The value contained
in one address field (value = A) is used directly. The other address
field, or an implicit reference based on opcode, refers to a register
whose contents are added to A to produce the effective address.
Displacement Addressing
• The general format of Displacement Addressing is shown in the
Figure
Displacement Addressing
Three of the most common use of displacement addressing are:
1. Relative addressing 
2. Base-register addressing
3. Indexing
Relative Addressing:
• For relative addressing, the implicitly referenced register is
the program counter (PC). That is, the current instruction address is
added to the address field to produce the EA. Thus, the effective
address is a displacement relative to the address of the instruction.
Displacement Addressing
Base-Register Addressing:
• The reference register contains a memory address, and the address
field contains a displacement from that address. The register
reference may be explicit or implicit.
• In some implementation, a single segment/base register is
employed and is used implicitly. In others, the programmer may
choose a register to hold the base address of a segment, and the
instruction must reference it explicitly.
Displacement Addressing
Indexing:
• The address field references a main memory address, and the
reference register contains a positive displacement from that
address. In this case also the register reference is sometimes
explicit and sometimes implicit.
• Generally index register are used for iterative tasks, it is typical that
there is a need to increment or decrement the index register after
each reference to it. Because this is such a common operation,
some system will automatically do this as part of the same
instruction cycle.
Displacement Addressing
• This is known as auto-indexing. We may get two types of auto
indexing:
• One is auto-incrementing and the other one is auto-decrementing.
• Auto-indexing using increment can be depicted as follows: 
           EA   =   A    +  (R) 
R     =  (R)  +   1
• Auto-indexing using decrement can be depicted as follows:
EA     =     A    +   (R)
R       =    (R)   -    1
Displacement Addressing

• If indexing is performed after the indirection, it is termed post-


indexing
EA     =   (A)    +   (R)

• With pre-indexing, the indexing is performed before the indirection:


EA    =    ( A    +    (R) )
Stack Addressing
Stack Addressing:
• A stack is a linear array or list of locations. It is sometimes referred
to as a pushdown list or last-in-first-out queue. A stack is a reserved
block of locations. Items are appended to the top of the stack so
that, at any given time, the block is partially filled.
• Associated with the stack is a pointer whose value is the address of
the top of the stack. The stack pointer is maintained in a register.
Thus, references to stack locations in memory are in fact register
indirect addresses.
Stack Addressing
Stack Addressing:

• The stack mode of addressing is a form of implied addressing. The


machine instructions need not include a memory reference but
implicitly operate on the top of the stack.
Examples w.r.t 8086 μP

1. Immediate addressing mode


Ex: MOV AL,55H
MOV BX, 0ABCDH
2. Register addressing mode
Ex: MOV AL,BL
MOV CX,DX
3. Implicit addressing mode
Ex: DAA
MUL BX
Examples w.r.t 8086 μP

4. Direct addressing mode


Ex: MOV 2000H, AL
MOV BL, 5000H
MOV 6000H, AX
5. Register indirect addressing mode
Ex: MOV AL, [BX]
MOV AX, [BX]
6. Register relative addressing mode
Ex: MOV AL, [BX]100H
MOV ARRAY[DI], AL
Examples w.r.t 8086 μP
7. Base index addressing mode
Ex: MOV DX, [BX][SI] or MOV DX,[BX + SI]
MOV [BP + DI],AL
8. Relative base index addressing mode (or) Base index with
displacement
Ex: MOV FILE[BX + SI],BL or DL
Instruction Set
• The operation of a CPU is determine by the instruction it executes,
referred to as machine instructions or computer instructions. The
collection of different instructions is referred as the instruction set
of the CPU.
• Each instruction must contain the information required by the CPU
for execution.
• Opcodes are represented by abbreviations, called mnemonics, that
indicate the operations
Instruction Set
The instruction set of a CPU can be categorized as follows:
• Data Processing
• Data Storage
• Data Movement
• Control

Types of Operands
• Addresses
• Numbers
• Characters
• Logical Data
Instruction Set

Types of Operations
1. Data Transfer
2. Arithmetic
3. Logical
4. Input Output [ I/O ]
5. System Control
6. Transfer Control
Data Transfer
• Move (Transfer) :Transfer word or block from source to destination
• Store: Transfer word from processor to memory
• Load (fetch): Transfer word from memory to processor
• Exchange: Swap contents of source and destination
• Clear (reset): Transfer word of 0s to destination
• Set: Transfer word of 1s to destination
• Push: Transfer word from source to top of stack
• Pop: Transfer word from top of stack to destination
Arithmetic
• Add: Compute sum of two operands
• Subtract: Compute difference of two operands
• Multiply: Compute product of two operands
• Divide: Compute quotient of two operands
• Absolute: Replace operand by its absolute value
• Negate: Change sign of operand
• Increment : Add 1 to operand
• Decrement: Subtract 1 from operand
Logical
• AND: Performs the logical operation AND bitwise
• OR: Performs the logical operation OR bitwise
• NOT: Performs the logical operation NOT bitwise
• Exclusive OR: Performs the specified logical operation Exclusive-OR
bitwise
• Test: Test specified condition; set flag(s) based on outcome
• Compare: Make logical or arithmetic comparison Set flag(s) based
on outcome
• Set Control Variables: Class of instructions to set controls for
protection purposes, interrupt handling, timer control etc.
• Shift: Left (right) shift operand, introducing constant at end
• Rotate: Left (right) shift operation, with wraparound end
Input/output
• Input (Read): Transfer data from specified I/O port or device to
destination (e.g., main memory or processor register)
• Output (Write): Transfer data from specified source to I/O port or
device.
• Start I/O: Transfer instructions to I/O processor to initiate I/O
operation.
• Test I/O: Transfer status information from I/O system to specified
destination
System Control
• System control instructions are those which are used for system

setting and it can be used only in privileged state.

• Typically, these instructions are reserved for the use of operating

systems.
Transfer of Control
The most common transfer-of-control operations found in instruction
set are:
1. Branch
2. Skip
3. Procedure call.
• BRP X: Branch to location X if result is positive
• BRN X: Branch to location X if result is negative
• BRZ X: Branch to location X is result is zero

• BRO X: Branch to location X if overflow occurs


Instruction Format

1. Zero Address Instruction


Op-Code

2. One Address Instruction


Op-Code Address

3. Two Address Instruction


Op-Code Address-1 Address-2

4. Three Address Instruction


Op-Code Address-1 Address-2 Address-3
Zero address instructions
One address instructions

LOAD A A C <- M [ A ]
ADD B A C <- A C + M [ B ]
STORE T M [ T ] <- A C
LOAD C A C <- M [ C ]
ADD D A C <- A C + M [ D ]
MUL T A C <- A C • M [ T ]
STORE X M [ X ] <- A C
Two address instructions

MOV R1 , A R 1 <--M [ A ]

ADD R1 , B R 1 <--R 1 + M [ B ]

MOV R2 , C R 2 <--M [ C ]

ADD R2 , D R 2 <--R 2 + M [ D ]

MUL R1 , R2 R 1 <--R 1 * R 2

MOV X , R1 M [ X ] <--R 1
Three address instructions

ADD R1 , A , B R 1 <--M [ A ] + M [ B ]

ADD R2 , C , D R 2 <--M [ C ] + M [ D ]

MUL X , R1 , R2 M [ X ] <--R 1 * R 2
END
OF
CO -1

You might also like