Programming-8085
Programming-8085
Language Programming
Programming Model
The 8085 programming model includes six general purpose registers, one
accumulator, and one flag register. In addition, it has two 16-bit registers
named as the stack pointer and the program counter.
Bidirectional Unidirectional
Programming Model
Accumulator
The accumulator, identified as A, is an 8-bit register which is part of
the arithmetic/logic unit (ALU).
It is used to store 8-bit data and to perform arithmetic and logical
operations (Second operation).
It is used to store the result of an operation.
It is also used to store 8 bit data during I/O transfer.
Flag register
It is an 8-bit register adjacent to the accumulator and part of the ALU.
It is not used as an 8-bit register; five bit positions, out of eight, are used
to store the outputs of the five flip-flops.
Programming Model
The bit positions in the flag register are shown in the following figure
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
In the flag register, the flip-flop which is used to indicate a zero result
in the accumulator is called zero flag.
This flag is set to 1, when the result is zero; otherwise it is reset.
Programming Model
Instruction
An instruction is a binary pattern designed inside a microprocessor to
perform a specific function. The entire group of instructions, called the
instruction set, determines what functions the microprocessor can perform.
The 8085 microprocessor instruction set has 74 operation codes that result
in 246 instructions. This instruction set includes all the 8080A instructions
plus two additional instructions namely SIM and RIM.
Classification
The instruction set of 8085 microprocessor is classified into five categories.
They are:
Arithmetic Operations
This group of instructions performs arithmetic operations such as addition,
subtraction, increment and decrement.
The addition and subtraction operations are performed in relation to the
contents of the accumulator. But, the increment or the decrement operations
can be performed in any register.
ADD, ADI (Add Immediate), SUB (Subtract), SUI (Subtract Immediate), INR
(Increment), DCR (Decrement) etc., are the instructions of this group.
Examples
ADD B ; Add the contents of B register to the accumulator.
ADI 08H ; Add the data 08H to the accumulator.
SUB B ; Subtract the contents of B register from the accumulator.
SUI 05H ;Subtract immediate the data 05H from the accumulator.
INR B ; Increment the B register contents by one bit.
DCR C ; Decrement the C register contents by one bit.
Arithmetic instructions modify all the flags according to the data conditions of
the result. The INR and DCR instructions affect all flags except the carry flag.
Classification of Instructions
Logical Operations
Since the microprocessor is a programmable logic chip, it can be performing
all the logic functions of the hard-wired logic through its instruction set of this
category.
The various logic functions (such as AND, OR, Exclusive-OR, Rotate,
Compare, Complement (NOT) etc.) are performed in relation to the contents of
the accumulator.
The executions of the logical instructions do not affect the contents of the
operand register.
Examples
ANA : Logically AND the contents of a register
ANI : Logically AND immediate the 8-bit data.
ORA : Logically OR the contents of a register.
OR : Logically OR immediate the 8-bit data.
XRA : Exclusive-OR the contents of a register.
XRI : Immediate Exclusive-OR the 8-bit data
CMA : Complement the accumulator
The CMA instruction does not affect any flags.
Classification of Instructions
Branching Operations
This group of instructions alters the sequence of program execution
either conditionally or unconditionally.
The branch instructions instruct the microprocessor to go to a different
memory location and the processor continues executing machine codes
from the new location.
The address of the new location either specified explicitly or provided by
the microprocessor or some times by additional hardware.
The Branch instructions are classified into three categories. They are:
Jump Instructions
Call and Return Instructions
Restart Instructions
Jump Instructions
The Jump instructions specify the memory locations explicitly. They are 3-byte
instructions: one byte for the operation code, followed by a 16-bit memory
address. Jump instructions are classified into two categories. They are:
Unconditional Jump
Conditional Jump
Classification of Instructions
Unconditional Jump
The unconditional branch instructions transfer the program to the specified
label/location unconditionally. This is similar to Unconditional Go to statement
in BASIC.
This Unconditional Jump instruction enables the programmer to set up
continuous loops.
The 8085/8080A includes one unconditional Jump Instruction.
Example
JMP 8500H (16-bit memory address)
Which instructs the microprocessor to go to the memory location 8500H
unconditionally.
Conditional Jump
The conditional branch instructions transfer the program to the specified
label/location when certain condition is satisfied.
This instruction allows the microprocessor to make decision depending
on certain conditions indicated by flags.
In the 8085/8080A microprocessor, Carry flag (CY), Zero flag (Z), Sign flag
(S) and Parity flag (P) are used by the conditional Jump instructions.
In the 8085/8080A microprocessor, all conditional Jump instructions are
3-byte instructions; the first byte specifies the operation code, the second
byte specifies the low-order (line number) memory address, and the third
byte specifies the high-order (page number) memory address.
The conditional Call (CALL) and Return (RET) instructions also can test
condition flags
No flags are affected
Restart Instruction
The RST (Restart) instructions are equivalent to 1-byte call instructions to
one of the eight memory locations on page 00H (high-order memory address).
In other words, the 8085/8080A microprocessor provides eight RST
instructions to transfer the program control to one of eight memory locations
on page 00H.
These instructions are generally used in conjunction with interrupts and
inserted using external hardware.
Mnemonics Hex Code Restart/Call address
RST 0 C7 0000H
RST 1 CF 0008H
RST 2 D7 0010H
RST 3 DF 0018H
RST 4 E7 0020H
RST 5 EF 0028H
Classification of Instructions
RST 6 F7 0030H
RST 7 FF 0038H
According to word size, the instruction set of the 8085/8080A can also be
classified into the following three groups:
One-word or 1-byte instructions
Two-word or 2-byte instructions
Three-word or 3-byte instructions
A 1-byte instruction includes the operation code (opcode) and the operand
in the same byte.
This instruction requires one memory location to store in memory.
Example
In a 2-byte instruction, the first byte specifies the operation code and the
second specifies the operand.
This instruction requires two memory locations to store in memory.
Example
Example
The 8085/8080A instruction set has the following five addressing modes:
Example
IN/OUT 8-bit Port Address ; Read/Write the data from the/into the 8-bit port
address
LDA 4000H ; Load the contents of memory location (4000H)
into the accumulator.
STA 8000H ; Store the contents of the Accumulator in the
memory location 8000H
Example
Add :10000
Register B : 000
to A : Implicit
Binary Instruction : 10000 000