COD Unit 2 PDF
COD Unit 2 PDF
Unit II
Computer Organization :
instruction codes, computer registers,
common bus system, computer instructions,
timing and control, instruction cycle,
Memory reference instructions,
input-output and interrupt
Instruction codes
• The control unit interprets the binary code of the instruction and proceeds
to execute it by issuing a sequence of micro-operations.
• The number of bits required for the operation code depends on the
total number of operations available in the computer
Read instruction
from memory
Instruction codes
• An operation must be performed on some data stored in processor
registers or in memory.
• An instruction code must therefore specify not only the operation, but
also the location of the operands (in registers or in the memory), and
where the result will be stored (registers/memory).
Instruction Format
Instructions
15 0
(program)
Binary Operand
Operands
(data)
15 0
Processor register
(Accumulator AC)
Instruction codes
Instruction Codes Addressing Modes
• There are three Addressing Modes used for address portion of the
instruction code:
• Direct: the address points to the operand stored in the
memory
• Indirect: the address points to the pointer (another
address) stored in the memory that references the
operand in memory.
• One bit of the instruction code can be used to distinguish between
direct & indirect addresses.
• Effective address: the address of the operand in a computation-type
instruction or the target address in a branch-type instruction.
Instruction codes
Instruction Codes Addressing Modes
Effective
Address
Definition - What does Macro Instruction mean?
A macro instruction is a group of programming instructions that have been compressed into a simpler form and
appear as a single instruction. When used, a macro expands from its compressed form into its actual instruction
details. Both the name of the macro definition and other variable parameter attributes are included within the
macro statement.
Explanation:
Macro instructions were first used in the assembler language rather than a higher-level programming language.
The way a macro expands to a set of instructions depends on the macro definition, which converts the macro into
its detailed instructional form.
Macros save developers much time and effort, especially when dealing with a certain sequence of commands
that is repeated more than once within the program body. Macros also save space and spare the programmer
time spent on a long code block that may pertain to performing a single function.
The concept of macros is used within some pre-compilers, while higher-level languages focus on simplifying
program and function writing, which makes the macro instruction a common element among most high-level
programming languages. Macro instructions are generated together with the rest of the program by the
assembler.
Share this:
Computer Registers
• Computer instructions are normally stored in consecutive memory
locations and executed sequentially one at a time.
• It is also necessary to provide a register in the control unit for storing the
instruction code after it is read from memory.
T0
T1
T2
T3
T4
D3
CLR
SC
Timing & Control
• A memory read or write cycle will be initiated with the rising
edge of a timing signal
• Assume: memory cycle time < clock cycle time!
• So, a memory read or write cycle initiated by a timing signal will
be completed by the time the next clock goes through its positive
edge.
• The clock transition will then be used to load the memory word
into a register.
• The memory cycle time is usually longer than the processor clock
cycle → wait cycles
Timing & Control
T0: AR←PC
• Transfers the content of PC into AR if timing signal T0 is
active
• T0 is active during an entire clock cycle interval
• During this time, the content of PC is placed onto the
bus (with S2S1S0=010) and the LD (load) input of AR is
enabled
• The actual transfer does not occur until the end of the
clock cycle when the clock goes through a positive
transition
• This same positive clock transition increments the
sequence counter SC from 0000 to 0001
• The next clock cycle has T1 active and T0 inactive.
Instruction Cycle
S2
T0 S1 Bus
S0
Memory
7
unit
Address
Read
AR 1
LD
PC 2
INR
IR 5
LD Clock
Instruction Cycle : Fetch and Decode
T0
AR PC
T1
IR M[AR], PC PC + 1
T2
Decode Opcode in IR(12-14),
AR IR(0-11), I IR(15)
T3 T3 T3
Execute Execute AR M[AR] Nothing
input-output register-reference
instruction instruction
SC 0 SC 0 Execute
memory-reference
instruction
SC 0
Instruction Cycle : Fetch and Decode
MEMORY REFERENCE INSTRUCTIONS
Operation
Symbol Decoder Symbolic Description
AND D0 AC AC M[AR]
ADD D1 AC AC + M[AR], E Cout
LDA D2 AC M[AR]
STA D3 M[AR] AC
BUN D4 PC AR
BSA D5 M[AR] PC, PC AR + 1
ISZ D6 M[AR] M[AR] + 1, if M[AR] + 1 = 0 then PC PC+1
- The effective address of the instruction is in AR and was placed there during
timing signal T2 when I = 0, or during timing signal T3 when I = 1
- Memory cycle is assumed to be short enough to be completed in a CPU cycle
- The execution of MR Instruction starts with T4
AND to AC
D0T4: DR M[AR] Read operand
D0T5: AC AC DR, SC 0 AND with AC
ADD to AC
D1T4: DR M[AR] Read operand
D1T5: AC AC + DR, E Cout, SC 0 Add to AC and store carry in E
Instruction Cycle : Fetch and Decode
- D7 = 1, I = 0
REGISTER REFERENCE INSTRUCTIONS
- Register Ref. Instr. is specified in B0 ~ B11 of IR
- Execution starts with timing signal T3
LDA: Load to AC
D2T4: DR M[AR]
D2T5: AC DR, SC 0
STA: Store AC
Memory, PC, AR at time T4 Memory, PC after execution D3T4: M[AR] AC, SC 0
20 0 BSA 135 20 0 BSA 135 BUN: Branch Unconditionally
Return address: PC = 21 Next instruction 21 Next instruction D4T4: PC AR, SC 0
BSA: Branch and Save Return Address
M[AR] PC, PC AR + 1
AR = 135 135 21
136 Subroutine PC = 136 Subroutine
Memory Memory
Instruction Cycle : Fetch and Decode
MEMORY REFERENCE INSTRUCTIONS