CO - 22CSE132 - Module 1
CO - 22CSE132 - Module 1
Institute of Technology
Semester: III B
Course Name: Computer Organization
Course Code:22CSE132
Manjushree K,
Assistant Professor,
Dept of CSE
Module 1
Chapter 1: Basic Structure of Computers
Functional Units
• The timing signals that govern the I/O transfers are also
generated by the control unit.
Basic Operational Concepts
• Individual instructions are brought from the memory into the
processor to executes it.
PC
IR
Memory
MDR
R0
R1
Rn - 1
Control
ALU
Processor
and memory
n general purpose
registers
Fi gure 1.2. Connecti ons between the processor and the m em ory.
8. When the operand has been read from the memory to the MDR, it
is transferred from MDR to the ALU.
9. After one or two such repeated cycles, the ALU can perform the
desired operation.
11. Address of location where the result is stored is sent to MAR & a
write cycle is initiated.
Buffer Registers
→ are included with the devices to hold the information during
transfers.
ii) Reducing the amount of processing done in one basic step , also
makes it possible to reduce the clock period P.
Big-Endian Little-Endian
Big - Endian and Little - Endian Assignments
Consider a 32-bit integer (in hex): 0x12345678 which consists of 4
bytes: 12, 34, 56, and 78.
Hence this integer will occupy 4 bytes in memory.
Assume, we store it at memory address starting 1000.
On little-endian, memory will look like
For example
Statements,
R<-[LOC]
R3<-[R1]+[R2]
• The contents of a location are denoted by placing square brackets
around the name of the location.
Assembly Language Notation
• To represent machine instructions and programs, assembly language
format can be used.
Example,
i) Move LOC, R1;
ii) Add R1, R2, R3;
Example
Add A,B,C;
X = (A + B) ∗ (C + D)
LOAD A AC ← M [A]
ADD B AC ← A [AC] + M [B]
STORE T M [T] ← AC
LOAD C AC ← M [C]
ADD D AC ← AC + M [D]
MUL T AC ← AC ∗ M [T]
STORE X M [X] ← AC
Zero Address instruction
X = (A + B) ∗ (C + D)
PUSH A TOS ← A
PUSH B TOS ← B
ADD TOS ← (A + B)
PUSH C TOS ← C
PUSH D TOS ← D
ADD TOS ← (C + D)
MUL TOS ← (C + D) ∗ (A + B)
POP X M [X] ← TOS
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-straight-line sequencing.
3) During the execution of each instruction, the PC is incremented by 4
to point to the next instruction.
i) Fetch phase, instruction is fetched from the memory location and
placed in the IR of the processor.
ii) Execute phase, contents of IR is examined to determine which
operation is to be performed. The specified operation is then performed
by the processor.
A program for C = [A] + [B]
Branching
Consider the task of adding a list of n numbers.
• Number of entries in the list n is stored in memory location N.
• Register R1 is used as a counter to determine the number of time
the loop is executed.
• Contents of location N are loaded into register R1 at the beginning
of the program.
• Loop is a straight line sequence of instructions executed as many
times as needed. It starts at location LOOP and ends at the
instruction Branch>0.
• During each pass through this loop,
address of the next list entry is determined
entry is fetched and added to R0.
• Instruction Decrement R1 reduces the contents of R1 by 1 each
time through the loop. Then Branch instruction loads a new value
into the program counter.
Register mode
• Operand is the contents of a register.
• Name of the register is given in the instruction.
• Registers are used as temporary storage locations where the data in a
register are accessed.
• Example: instruction Move R1, R2
Absolute mode
• Operand is in a memory-location.
Immediate Mode
• Operand is given explicitly in the instruction.
• Clearly, the immediate mode is only used to specify the value of a source-
operand.
Example: instruction Move #200, R0 ;
First time through the loop, the instruction Add (R2), R0 fetches
the operand at location NUM1 and adds it to R0.
Index mode
Contents of the index-register are not changed in the process of generating the
effective address.
→ as an explicit number
The index register, R1, contains the address of a memory location, and the
value X defines an offset from this address to the location where the
operand is found.
• Second register may be used to contain the offset X and know as base
register.
Auto-increment Mode
MOVE R0,SUM;
The instruction
ADD #5,R3 ;
• Adds the number 5 to the contents of register R3 and puts the result
back into register R3.
Assembler Directives
• Directives are the assembler commands to the assembler concerning
the program being assembled. These commands are not translated
into machine opcode in the object program.
• EQU informs the assembler about the value of an identifier.
Ex: SUM EQU 200 ;
• This statement informs the assembler that the name SUM should be
replaced by the value 200 wherever it appears in the program.
• ORIGIN tells the assembler about the starting-address of memory-
area to place the data block. EX: ORIGIN 201
• DATAWORD directive tells the assembler to load a value (say 100)
into the location (say 204).
Ex: N DATAWORD 100;
Assembler Directives
• RESERVE directive declares that a memory-block of 400 bytes is
to be reserved for data and that the name NUM1 is to be associated
with address 208.
• END directive tells the assembler that this is the end of the source-
program text.
1. Program Controlled
2. Memory Mapped
• Move Byte operation code signifies that the operand size is a byte.
• Test bit instruction tests the state of one bit in the destination,
where the bit position to be tested is indicated by the first operand.
Stacks and Queues
• Stack is a list of data elements with the accessing restriction that
elements can be added or removed at one end of the list only. This
end is called the top of the stack, and the other end is called the
bottom.
• The terms push and pop are used to describe placing a new item
on the stack and removing the top item from the stack,
respectively.
Subtract #4,SR
Move NEWITEM,(SP)
Move (SP),ITEM
Add #4,SP
Routine for a safe pop and push operation as follows
Checking for empty and full errors in pop and push operations
Queues
Data are stored in and retrieved from a queue on a FIFO basis.
1) One end of the stack is fixed while the other end rises and falls as
data are pushed and popped.
• In this case, the return-address of the second call is also stored in the
link-register, destroying its previous contents.
• The work-space is
Add #12,SP
• And subroutine pops saved old value of FP back into FP. At this
point, SP points to return-address, so the Return instruction can
be executed, transferring control back to the calling program.
Stack Frames For Nested Subroutines
• The details of how the shifts are performed depend on whether the
operand is a signed number or some more general binary-coded
information.