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

Lecture 03

Uploaded by

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

Lecture 03

Uploaded by

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

CSC-430

Computer Organization &


Assembly Language

Prof. Dr. Imtiaz Ali Korejo


Email: [email protected]
Registers
❖Register is a temporary memory location inside the CPU, where we
can store data temporarily during the execution of CPU
of the program.

• Slow Fast
Registers

Hard Disk RAM Cache


Registers
❖Fastest storage location in CPU
❖The size of registers varies from CPU to CPU
There are different types of registers .
a) General purpose Registers
b) Segment Registers
c) Index Registers
d) Flag Registers
e) Special purpose Registers
Intel 8086 Microprocessor Organization

IN YU'S BOOK ON PAGE 08


General Purpose /Data Registers
Following four registers are available to the programmer for general
data manipulation:
❖AX(Accumulator Register): It is used in Arithmetic, logic and data
transfer instructions. AX required in input/output, multiplication,
division operations.
❖BX (Base Register): To hold the address of variable.
❖CX(Counter Register): Act as a counter for repeating or looping
instructions.
❖DX(Data Register): Dx is applied in multiplication, division and
input/output operations.
Segment Registers
To hold addresses of instruction and data in memory. These values are
used by the processor to access memory locations.
❖Code Segment(CS): Defines the starting address of the section of
memory holding code.
❖Data Segment(DS): The .data section is used to declare the memory
region, where data elements are stored for the program.
❖Stack Segment(SS): This segment contains data values passed to
functions and procedures within the program.
❖Extra Segment(ES): This segment is an additional segment.
Pointers and Index Registers
Instruction Pointer(IP): To hold the next instruction to be executed. IP
register work together with CS segment registers.
80386/80486 Extended Registers
❖Name storage locations inside the CPU, Optimized for speed.
32-bit General-Purpose Registers

EAX EBP
EBX ESP
ECX ESI
EDX EDI

16-bit Segment Registers

EFLAGS CS ES
SS FS
EIP
DS GS

IN KIP”S BOOK IN PAGE 38


Accessing Parts of Registers
• Use 8-bit name, 16-bit name, and 32-bit name
• Applies to EAX, EBX, ECX, and EDX

8 8

AH AL 8 bits + 8 bits

AX 16 bits

EAX 32 bits
Special Purpose Registers
❖These register are designed for special purpose.
❖These are used by control unit to control the operation of CPU.
❖The operating system uses them to control the execution of
programs.
Types of Special Purpose Registers:
❖ PC (Program Counter )
❖IR ( Instruction Register)
❖MAR (Memory Address Register )
❖MBR ( Memory Buffer Register )
Instruction Cycle or execution
 Fetch → Decode → Execute
 Fetch
1. Fetch an instruction from memory
2. Decode the instruction to determine the operation
3. Fetch data from memory if necessary
 Execute
4. Perform the operation on the data
5. Store the result in memory if needed
Program Counter
The PC register contains the address of the next instruction to be
fetched for execution.
❖Fetch
❖Decode Memory
❖Fetch Operands 1000 A+B
1001 B-3
❖Execute 1002
❖Store output 1003
1004
PC • 1005
PC
• 1000
1000 1006
PC
1001
Instruction Register
• Instruction Register(IR): Instruction is fetched by memory, which is
stored in the IR register where the instruction is decoded.

Memory
1000 A+B
IR Regsiter
1001 B-3
Opcode Operand1 Operand2 1002
+ A B 1003
1004
1005
1006
Memory
Bits, Bytes and Double words
Byte Byte
0 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1
Common Prefix
Main Memory
❖Most of the main memory in a general purpose computer is made up of RAM
integrated circuits chips, but a portion of the memory may be constructed with
ROM chips
• Memory Circuits:
• RAM
• Program Data and Instructions
• Read and Write
• ROM
• Used for storing an initial program called bootstrap loader, which is required to start the
computer software operating when power is turned off.
• Only Read
Memory Organization
❖Memory is organized into a collection of bytes.

❖Each byte is identified by a number – Address


• Number of bits in an address depends on the processor
• Example:- Intel 8086: 20-bit address, Intel 80286: 24-bit address

❖Data stored in a memory byte – Contents


❖ Number of bits used in the address determines the number of bytes that can be
accessed by the processor.

❖ Example: If
processor uses 20-bit address, it can access 220 = 1048576 bytes =
1 MB of memory.

❖ Question: If processor uses 24-bit address, how many bytes of memory can be
accessed?
Memory Segment
❖ The base address of a segment is called segment address
❖ A memory segment is a block of 216 (or 64 K) consecutive memory bytes.
❖ Each segment has a number.
❖ Within a segment, memory location is specified by an offset. This is the number of bytes
from the beginning of the segment.
❖ Logical address:
❖ The logical address is also called virtual address. Which is a reference to access the physical
address.
❖ The set of all logical addresses is generated by CPU.

❖A physical address is an actual location in main memory. When the processor execute a
process, it automatically converts from logical to physical address by adding the current
starting location of the process, called its base address to each logical address. Physical
address is generated by Memory Management Unit (MMU).
Illustration
LOGICAL ADDRESS PHYSICAL ADDRESS
Segment Beginning Last Beginning Last
Number Address Address Address Address
0000 0000:0000 0000:FFFF 00000 0FFFF
0001 0001:0000 0001:FFFF 00010 1000F
0002 0002:0000 0002:FFFF 00020 1001F
0003 0003:0000 0003:FFFF 00030 1002F
. . . . .
. . . . .
. . . . .
FFFF FFFF:0000 FFFF:FFFF FFFF0 0FFEF
Calculate the Physical, Segment, offset
address & Examples
Formula of physical address
Physical add = Segment * 10 + Offset add
Given an address of AB9C:79A5 calculate the physical address.
Phy = seg *10 + off
= AB9C *10 + 79A5
= AB9C0 + 79A5
Phy add = B3365 Ans
Examples (Cont’d)
Given a Physical address of A2B94 that you know has an offset of F7B4
in some segment number, Calculate the segment number the address is
in.
Physical address = segment *10 + offset
A2B94 = segment *10 + F7B4
segment *10 + F7B4 = A2B94
segment *10 = A2B94 – F7B4
segment = 933E0 / 10
segment = 933E Ans
THE END.

You might also like