1
Processor Memory(Registers)
Sept Dec 2024 01/22/2025
2
PROCESSOR MEMORY
(REGISTERS)
Sept Dec 2024 01/22/2025
Microprocessor Registers
3
Microcomputer memory system can
logically be divided into three groups:
Processor memory
Primary or main memory
Secondary memory
Sept Dec 2024 01/22/2025
Cont.
4
Processor memory refers to a set of
microprocessor registers. These registers
form storage locations in a CPU.
They are used to hold data/addresses when
execution of an instruction is in progress.
Processor registers and the microprocessor
are fabricated using the same technology.
They have faster access time than primary
memory.
Sept Dec 2024 01/22/2025
Cont.
5
The number of registers available for
programming in a microprocessor vary with
different processors.
8085 microprocessor registers are:
The Accumulator(A), B,C,D,E,H,L, Flag
Register, Stack Pointer(SP),Program
Counter(PC).
Sept Dec 2024 01/22/2025
Program Counter(PC)
6
It is 16 bits long.
The Program Counter is used to address up
to 64K of memory. It is always holding the
address of the next instruction to be fetched
from memory.
It enables the processor to read successive
instructions that are stored in the memory.
PC is modified with new address when there
is a jump, transfer of control or
subroutine call instructions.
Sept Dec 2024 01/22/2025
Stack Pointer(SP)
7
A Stack is an area in memory(RAM) that is
used for temporary storage of data or return
addresses.
A SP is a register that points to the next free
location in the stack.
Each time a byte is put onto the stack, SP is
decremented.
Each time a byte is retrieved from the stack,
SP is incremented.
Sept Dec 2024 01/22/2025
Cont.
8
The PUSH command is used to store contents
in the stack and the POP command retrieves
stored contents.
Sept Dec 2024 01/22/2025
Programming
9
A microprocessor is driven by a set of
instructions to perform specific tasks.
An instruction is a statement that becomes
executable when a program is assembled
A program can be written in
Machine Language,
Low Level Language(Assembly Language),
High Level Language such C, Java
Instructions are translated by the assembles
into machine language bytes, which are
loaded and executed by the CPU at runtime.
Sept Dec 2024 01/22/2025
cont.
10
Assembly can be done manually by the
programmer looking up the codes in the
instructions set (hand assembly) or by the
machine using the assembler.
An instructions set contains all the
instructions that a particular type of
microprocessor can execute.
Sept Dec 2024 01/22/2025
Instructions
11
An instruction contains four basic parts;
Label (optional)
Instruction Mnemonic (required)
Operand(s) (usually required )
Comment (optional)
Sept Dec 2024 01/22/2025
12
The different parts of an instruction is
arranged as shown bellow;
[Label:] mnemonic [operands] [; comment]
Label is an identifier that acts as a place
marker for instructions and data. A label
placed just before an instruction implies the
instruction's address. Similarly , a label
placed just before a variable implies the
variable’s address.
There are two types of labels; Data labels and
Code labels
Sept Dec 2024 01/22/2025
13
A data label identifies the location of a variable,
providing a convenient way to reference a
variable in the code. The following , for example,
defines a variable named count:
count DWORD 100
It is possible to define multiple data items following
a label. In the following example , array defines
the location of the first number(1024). The other
numbers will follow in memory immediately
afterwards
Sept Dec 2024 01/22/2025
14
array DWORD 1024 , 2048
DWORD 4096, 8192
A label in code area of a program (where
intructions are located) must end with (:)
character. Code labels are used as targets of
jumping and looping instructions.
Sept Dec 2024 01/22/2025
15
For example, the following JMP (jump)
instruction transfers control to the location
named target, creating a loop
target:
mov ax, bx
……
jmp target
Sept Dec 2024 01/22/2025
16
A code label can share the same line with
an instruction, or it can be on a line by itself:
L1:
L2: mov ax, bx
Sept Dec 2024 01/22/2025
Instruction Mnemonic
17
An instruction mnemonic is a short word that
identifies an instruction. In English, a mnemonic
is a device that assist memory. Similarly,
assembly language instruction mnemonics such
as mov, add, and sub provide hints about the
type of operation they perform .
Following are examples of instruction mnemonics
Mnemonic Description
MOV move (assign) one value to
another
Sept Dec 2024 01/22/2025
18
ADD Add two values
SUB subtract one value from
another
JMP Jump to a new location
CALL Call a procedure
Sept Dec 2024 01/22/2025
Operands
19
An operand is a value that is used for input or
output for an instruction. Assembly language
instruction can have between zero and three
operands, each of which can be a register,
memory operand, integer expression, or
input-output port.
The STC instruction, for example, has no
operands
stc ;set Carry flag
The INC has one operand;
inc eax ;add 1 to EAX
Sept Dec 2024 01/22/2025
20
The MOV instruction has two operands:
MOV count, ebx ;move ebx to count
There is a natural ordering of operands.
When instructions have multiple operands,
the first one is typically called the destination
operand. The second operand is usually
called the source operand.
In general, the content s of the destination
operand are modified . In the MOV
instruction, data is copied from the source to
the
Sept destination
Dec 2024 01/22/2025
Comments
21
Comments are an important way for the
writer of a program to communicate
information about the program’s design to a
person reading the source code
Sept Dec 2024 01/22/2025
example
22
Label Mnemonic Operand Comment
START: MVI A, 22H ;Move 2216 to Register A
ADI 20H ;Add 2016 to Register A
contents
LXI H, 8400H ;Load register pair HL
with 840016
MOV M, A ;Move contents of Reg A
into location 840016
JMP START ;Jump to START
Sept Dec 2024 01/22/2025
Instruction Types
23
An instruction normally has two components,
the operation code (Opcode) and the data or
address to be operated on (Operand).
To perform an operation, operands must be
given.
Operands can come from registers, memory
locations or directly (Immediate) as part of
instructions.
Sept Dec 2024 01/22/2025
Instruction Groups
24
Generally instructions available in a
microprocessor may be broadly classified
into five groups
Data transfer
Arithmetic
Logical
Program control
Input/Output
Sept Dec 2024 01/22/2025
Data Transfer Instructions
25
Instructions for moving/transferring data
between the processor and main memory.
Register to Register
Register to Memory
Memory to Register
Memory to Memory
Example
MOV B,C ; the instruction moves contents of register C
to register B.
Sept Dec 2024 01/22/2025
Arithmetic Instructions
26
All instruction sets include ADD and
SUBTRACT instructions. Some also include
multiplication and division.
To facilitate floating point number
manipulations, some processors include
floating-point instructions in their
instructions set.
Example ADD B; Add contents of register B to
the contents in the accumulator.
Sept Dec 2024 01/22/2025
Logical Instructions
27
These includes instructions for performing
the Boolean AND, NOT, OR, and EXCLUSIVE-
OR operations on a bit-by-bit basis.
Also included are SHIFT instructions:
Shift left or right
Rotate left or right
Sept Dec 2024 01/22/2025
Program Control Instructions
28
Instructions are always executed in the same
order they are represented. In a real-life
situation, flow of control depends on the
results of computation.
Based on the results of a computation, a
program can select a particular sequence of
instructions to execute.
Instructions that realize this approach are
called program control instructions.
Sept Dec 2024 01/22/2025
cont
29
Program Control instructions may be
classified into the following groups:
Unconditional branch instructions
Conditional branch instructions
Subroutine call instructions
Sept Dec 2024 01/22/2025
..
30
Unconditional Branch Instruction
transfers control to a specified address
regardless of the status of a computation.
A conditional Branch instruction
transfers control when some condition is
met after a computation.
if(condition) then branch to execute a new
instruction else the instructions that follow.
Sept Dec 2024 01/22/2025
.
31
Subroutine call.
A subroutine is a special program for
performing repeatedly needed tasks such as
sorting, searching…
In this case the control of the program will
now change to execute the subroutine.
Control returns after finishing with the
subroutine.
Sept Dec 2024 01/22/2025
Instructions set
32
8085 has a total of 246 instructions (see
table)
Familiarization with the instructions set
Sept Dec 2024 01/22/2025