0% found this document useful (0 votes)
11 views23 pages

Binary Pattern: Program An Instruction

Uploaded by

Muhammad Farhal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views23 pages

Binary Pattern: Program An Instruction

Uploaded by

Muhammad Farhal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Instruction Set of 8085 Microprocessor (Programming):

A microprocessor performs a task by executing a program written for


that task.
Program is a set of instructions written to solve a problem. And an
instruction is a binary pattern designed inside a MPU which it follows
to execute a task or part of a task on specified data. (1)

o The entire group of instructions that a microprocessor supports is


called instruction set which determines what functions the
microprocessor can perform.

Instruction Format:
Each instruction has two parts.
 One is the task or operation to be performed called the
operation code opcode.
 The second is the data to be operated on Called the operand.
The operand can be specified as 8-bit (or 16-bit) data, an internal
register, a memory location, or 8-bit (or 16-bit) address.

Instruction Word Size: According to word size, the 8085 instruction


set is classified as:
1. 1-byte or One-word instructions
2. 2-byte or Two-word instructions
3. 3-byte or Three-word instructions (2)

1-Byte Instructions:
It includes the opcode and operand in the same byte. Operand(s) are
internal registers and are coded into the instruction. These instructions
can perform three different tasks as shown in the Fig.
These instructions are stored in 8-bit binary format in one memory
location.
2-Byte Instructions:
The 1st byte specifies the opcode and the 2nd byte specifies the
operand. The operand may be a data or an address, e.g. MVI 𝐴, 35H
and IN 29H. (3)

These instructions are stored in two memory location.


3-Byte Instructions:
The 1st byte specifies the opcode and the following two bytes specifies
the 16-bit operand, the 2nd byte is the low-order operand and the 3rd
byte is the high-order operand. The operand may be a data or an
address, e.g. in LXI H, 3500H and STA 2500H, etc.
These instructions are stored in three memory location.

Opcode Format:
The instructions or operation are specified by using specific bit pattern
unique for each instruction, which contain all the information about
operations, registers, memory, and status flags to be used. (4)

o Some of the operation codes


(opcode), their intended
functions, operands to be
operated on, and their
respective binary & hex codes
are identified as follows.
Function Opcode Operand Binary Code Hex Code
Rotate each bit of the RLC A 00000111 07H
Accumulator A to the left by (5-bits) (3-bits) (8-bit)
one position.
Add the contents of a register ADD B 10000 000 80H
to the Accumulator A. (5-bits) (3-bits)

Move (Copy) the contents of a MOV C, A 01 001 111 4FH


source register 𝑅𝑠 to (2-bits)
destination register 𝑅𝑑 .

The assembly language mnemonics


Instruction Set Classification:
The instructions of 8085 microprocessor can be classified into five
functional categories as follows:
1. Data transfer (copy) operations 4. Branching operations
2. Arithmetic operations 5. Machine-control operations
3. Logical operations (5)
Data Transfer (copy) Operations :
The data is copied from a location called a source to another location
called a destination without modifying the contents of the source.
e.g. MOV, MVI, LDA, and STA (6)

o They transfer:
 Data between registers: e.g. copy the contents of register B into
register D.
 Data Byte to a register or memory location: e.g. load register B
with the data byte 32H.
 Data between a memory location and a register: e.g. from the
memory location 2000H to register B.
 Data between an I/O Device and the accumulator: e.g. from an
input keyboard to the accumulator.
o The data in the source is not changed, only the data of the
destination is changed.
o An I/O device can transfer or receive data from the accumulator but
not from other registers (except for the memory mapped I/O device).
o The LXI instruction (Load eXtended Immediate):
The 8085 provides an instruction to place the 16-bit data into the
register pair in one step. LXI Rp, <16-bit address>
– The instruction LXI B 4000H will place the 16-bit number 4000 into
the register pair B, C. The upper two digits are placed in the 1st register
of the pair and the lower two digits in the 2nd.

Arithmetic Operations:

These instructions perform arithmetic operations, such as addition,


subtraction, increment, and decrement. (7)

 Addition(ADD, ADI):
‒ Any 8-bit number
‒ The contents of a register
‒ The contents of a memory location
• Can be added to the contents of the accumulator and the result is
stored in the accumulator.
 Subtraction(SUB, SUI):
‒ Any 8-bit number
‒ The contents of a register
‒ The contents of a memory location
• Can be subtracted from the contents of the accumulator and the
result is stored in the accumulator. No two other registers can be
subtracted directly.

 Arithmetic Operations Related to Memory:


These instructions perform an arithmetic operation using the
contents of a memory location while they are still in the memory. (8)

‒ ADD M: Add the contents of M to the Accumulator.


‒ SUB M: Sub the contents of M from the Accumulator
‒ INR M/ DCR M: Increment/decrement the contents of the memory
location in place.
 Increment (INR) and Decrement(DCR):
• The 8-bit contents of any memory location or any register or 16
-bit contents of a register pair can be directly incremented or
decremented by 1.
• No need to disturb the contents of the accumulator A.
Manipulating Addresses: Now that we have a 16-bit address in a
register pair, how do we manipulate it?
‒ It is possible to manipulate a 16-bit address stored in a register pair
as one entity using some special instructions.
INX Rp (Increment the 16-bit number in the register pair)
DCX Rp (Decrement the 16-bit number in the register pair) (9)

‒ The register pair is incremented or decremented as one entity. No


need to worry about a carry from the lower 8-bits to the upper. It is
taken care of automatically.
Logical Operations :

These instructions perform logic operations on the contents of the


accumulator. ANA, ANI, ORA, ORI, XRA and XRI (10)

 Source: Accumulator and


‒ An 8-bit number
‒ The contents of a register
‒ The contents of a memory location
 Destination: the result is stored in the Accumulator
‒ Complement:
• 1’s complement of the contents of the accumulator.
CMA No operand
(11)

‒ Compare:
• Compare the contents of a register or memory location with the
contents of the accumulator.
Branch Operations :

The group of instructions that alters the sequence or program


execution either conditionally or unconditionally. (12)

 Unconditional Branch:
‒ JMP Address Jump to the address specified (Go to).
‒ CALL Address Jump to the address specified but treat it as a
subroutine.
‒ RET Return from a subroutine.
 Conditional Branch:
‒ Go to new location if a specified condition is met.
Machine Control Operations :
Writing & Executing a Simple Program in 8085 Assembly Language:
Write instructions to add two hexadecimal numbers, 32H & 48H, and
then save the answer in register C. (13)

o The steps needed are as follows:


 Load the number 32H in one register.
 Load the number 48H in another register.
 ADD the contents of the two registers.
 Save the sum in register C.
 End the program.

Opcode Operand Hex (machine) Code Comments


1. MVI A, 32H 3E 32 (2-byte) :Load the number 32H in the
accumulator A
2. MVI B, 48H 06 48 (2-byte) :Load the number 48H in the
register B
Opcode Operand Hex (machine) Code Comments
3. ADD B 80 (1-byte) :Add the content of register B
to the accumulator A, & the
sum is stored in A.
4. MOV C, A 4F (1-byte) : Copy the sum from A to C.
5. HLT 76 (1-byte) : End of the program
Entering & Executing the Program in Single-Board Microcomputer
o With Hex-keyboard and R/W memory the program is stored as:
 Reset the system
 Direct the MPU where your
program begins by pushing the
appropriate keys
 Execute the program
o The result (32+48 = 7AH) is
found in two registers_ A & C.
Example: Write a Program to load or store hexadecimal numbers: 49𝐻
and 35𝐻 in the memory location 2500𝐻 and 2501𝐻 .
To transfer these two immediate data, the instruction “MVI M, 8-bit
immediate data” and to specify the memory location we have to use HL
register pair as:
1. LXI H, 2500H
2. MVI M, 49H
3. LXI H, 2501H
4. MVI M, 35H

Example: Move the contents of the register pair DE to the memory


locations 9000𝐻 and 9001𝐻 .

The register pair contents can be transferred by first initializing the HL


register pair with the memory location & then using the MOV
instruction as:
1. LXI H, 9000H
2. MOV M, E
3. LXI H, 9001H
4. MOV M, D
Homework #1:

You might also like