Memory Basics
Memory Basics
Memory Basics
Sheeza Zaheer
Lecturer
University of Management and Technology
Lahore Campus
2
MEMORY
Bits, Bytes and Double words
byte byte 4
0 0 1 0 0 1 1 0 0 1 1 0 1 01 0
word
4
Memory
5
● Information processed by the computer is stored in its
memory.
■ Program
■ Data
● Not all accumulated information is needed by the CPU at the
same time
■ Therefore, it is more economical to use low-cost storage devices to
serve as a backup for storing the information that is not currently
used by CPU
● Memory Operations:
■ Read (Fetch contents of a location)
■ Write (Store data at a location)
5
Contd..
6
● The memory unit that directly communicate with CPU is called the
main memory
6
Contd..
7
7
Main Memory
8
● 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
○ ROM is used by the manufacturers to store system programs.
○ Only Read
8
Cache
9
● A special very-high-speed memory called cache is used to
increase the speed of processing by making current programs
and data available to the CPU at a rapid rate.
9
Memory Organization
10
10
Contd..
11
● Number of bits used in the address determines the number of
bytes that can be accessed by the processor.
11
Memory Segments
12
12
F0000
E0000 13
D0000
C0000
B0000
A0000 8000:FFFF
90000
One Segment
80000
70000 8000:0000
60000
50000
segment of f set
40000
30000
20000
10000
00000
13
Segment : Offset Address
14
14
Exercise
15
A memory location has a physical address 4A37Bh. Compute:
15
Program Segments
16
● A typical machine language program is loaded
into following different memory segments:
■ Code Segment
■ Data Segment
■ Stack Segment
● Stack is a data structure used by processor to
implement procedure calls.
16
17
19
Contd..
20
● Binary representations of machine instructions is difficult to
remember.
● Use a symbolic representation of machine instructions.
● Opcodes are represented by abbreviations, called mnemonics,
that indicate the operation. Common examples include:
20
Instruction Types
21
● Data processing: Arithmetic and logic instructions
● Data storage: Memory instructions
● Data movement: I/O instructions
● Transfer of Control: branch instructions
21
No. of Addresses in an Instruction
22
● Three addresses
■ Operand 1, operand 2, result
● Two addresses
■ Source
■ Destination
● One addresses
■ Source or Destination
● Zero address
■ Zero-address instructions are applicable to a special
memory organization, called a Stack. A stack is a last-in-
first-out set of locations.
22
Types of Operands
23
● Machine instructions operate on data.
● The most important general categories of data are:
■ Addresses
■ Numbers
■ Characters
23
Basic Operations – Processor
24
● Execute the software by fetching instruction from memory
● Look for any external signal and react accordingly
■ Input signals from keyboard or mouse etc.
24
Basic Instruction Cycle
25
● 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
25
Contd..
● Internal CPU Registers used in instruction 26
cycle:
■ Program Counter (PC) = Address of instruction
■ Instruction Register (IR) = Instruction being
executed
■ Accumulator (AC) = Temporary Storage
26
Detailed Steps
● Address in the Program Counter register 27
27
Example Program Execution
28
28
Instruction Cycle State Diagram
29
29
Contd..
30
● Instruction Fetch
■ Read instruction from memory into processor
● Instruction Operation Decoding
■ Determine the type of operation to be performed and operand(s)
to be used.
● Operand Address Calculation
■ If operation involves reference to an operand in memory or I/O,
then determine the address of operand.
● Operand Fetch
■ Fetch from memory or read from I/O
● Data Operation
■ Perform the operation
● Operand Store
■ Write into memory or out to I/O if required
30