Header Ads Widget

Programming with Intel 8085 Microprocessor

Programming with Intel 8085 Microprocessor





5.1 Instruction format and data format
An 8085program instructions format may be one, two or three length.

1. 1-byte instruction (8 bit)
1-byte instructionincludesoperand and opcode in the same byte. It occupies 1-byte space in memory.


E.g.
        Opcode         operand
        MOV             A, B
        ADD             B
        CMA

2. Byte instruction (16 bit)
In a 2-byte instruction, the first byte specifies the operation and second byte specifies opcode. It occupies 2-byte space in memory

Opcode DATA OR ADDRESS
E.g.
        Opcode         Operand
        MVI             A, 45H
        MVI             B, F2H

3. 3-byte instruction
In 3-byte instruction the first byte specifies the opcode and following two byte specifies the 16-bit address. It occupies 3-byte space in memory.

E.g.
    Opcode         Operand     Hex code
    LDA             2050H         3A
                                            50
                                            20
    JMP             2085H         C3
                                            85
                                            20

Instruction with a Memory Address
Operation: go to address 2085.
Instruction: JMP 2085
Opcode: JMP
Operand: 2085
Binary code
1100     0011     C3     1st byte
1000     0101     85     2nd byte
0010     0000     20       3rd byte
Data Format

In 8085, data stores in the form of 8-bit binary integer. In the Intel 8085, bit 0 is
referred as the least signification bit (LSB) and bit 7 is referred as most signification
bit (MBS).

Data can be represented in four formats

1. ASCII (American Standard Code for Information Interchange) e.g. - A-Z, a- z, 0-9 etc.
2. BCD (Binary Code Decimal) e.g. - 0-F
3. Signed Integer e.g. +2, +3,
4. Unsigned Integer e.g. -2, -3,


Assume the accumulator contains the following value: 0100 0001
There are four ways of reading this value:

It is an unsigned integer expressed in binary; the equivalent decimal number would be 65.

It is a number expressed in BCD (Binary Coded Decimal) format. That would make it, 41.

It is an ASCII representation of a letter. That would make it the letter A.

It is a string of 0’s and 1’s where the 0th and the 6th bits are set to 1 while all other bits are set to 0.

5.2 Intel 8085 instruction Set & Instructions types

An Instruction is a command given to the computer to perform a specified operation on given data. The instruction set of a  microprocessor is the collection of the instructions that the microprocessor is designed to execute. The instructions described here are of Intel 8085.The instruction set of the 8085 microprocessor
consists of 74 instructions with 246 different bit patterns. These instructions are of Intel Corporation. They cannot be used byother microprocessor manufactures. The programmer can write a program in assembly language using these instructions.

These instructions have been classified as below:
1. Data transfer instruction
This instruction copies data from one location to another location. There are various types of data transfers.

Between register
E.g. MOV A, B; MOV C, B etc.
Specify the data byte to register or memory location.
E.g. MVI B, 23H; LDA 2500H etc.

34 Microprocessor : Grade 10
Between memory location and register
E.g. LXI 2050H
Between input and output
E.g. IN 02H; OUT PORT1 etc.

2. Arithmetic instruction
This instruction performs arithmetic operation such as addition, subtraction, increment, and decrement. E.g. ADD B, ADI 25H, SUB C, SUI 23H, SUB M, INR
B, DCR A etc.

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. The result is stored in the accumulator.

Increment (INR) and Decrement (DCR)
 The 8-bit contents of any memory location or any register can be directly incremented or decremented by 1.
 No need to disturb the contents of the accumulator

3. Logical instruction
This instruction performs logical operation like AND, OR, COMPARE,
ROTATED.

CMP- compare
RAL- rotation left
RAR- rotation right
ANA- AND
ORA- OR

These instructions perform logic operations on the contents of the accumulator –

ANA, ANI, ORA, ORI, XRA and XRI

 Source: Accumulator and
– An 8-bit number
– The contents of a register
– The contents of a memory location

 Destination: Accumulator
ANA R/M AND Accumulator withReg/Mem
ANI # AND Accumulator With an 8-bit number
ORA R/M OR Accumulator withReg/Mem
ORI # OR Accumulator With an 8-bit number
XRA R/M XOR Accumulator withReg/Mem
XRI # XOR Accumulator With an 8-bit number

 Complement
 1’s complement of the contents of the accumulator.
CMA No operand
 Rotate – Rotate the contents of the accumulator one position to the left or
right.
– RLC Rotate the accumulator left. Bit 7 goes to bit 0AND the Carry flag.
– RAL Rotate the accumulator left through the carry. Bit 7 goes to the carry and carry goes to bit 0.

– RRC Rotate the accumulator right. Bit 0 goes to bit 7 AND the Carry flag.
– RAR Rotate the accumulator right through the carry. Bit 0 goes to the carry and carry goes to bit 7.

 Compare
 Compare the contents of a register or memory location with the contents of
the accumulator.
– CMP R/M     compares the contents of the register or memory location to the

contents of the accumulator.

– CPI #     Compare the 8-bit number to the contents of the accumulator.
 The compare instruction sets the flags (Z, Cy, and S).
 The compare is done using an internal subtraction that does not change the
contents of the accumulator.
A –(R / M / #)

4. Branch instruction
Two types

Unconditional branch
Go to a new location no matter what.

Conditional branch
Go to a new location if the condition is true.

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.
– The addresses supplied to all branch operations must be 16-bits.
Conditional Branch
– Go to new location if a specified condition is met.
JZ Address (Jump on Zero) – Go to address specified if the Zero flag is set.
JNZ Address (Jump on NOT Zero) – Go to address specified if the Zero flag is not
set.
JC Address (Jump on Carry) – Go to the address specified if the Carry flag is set.


JNC Address (Jump on No Carry) – Go to the address specified if the Carry flag is
not set.
JP Address (Jump on Plus) – Go to the address specified if the Sign flag is not set
JM Address (Jump on Minus) – Go to the address specified if the Sign flag is set.

5. Machine Control
– HLT
Stop executing the program. – NOP
No operation
Exactly as it says, do nothing.
Usually used for delay or to replace instructions during debugging.
These instruction control machines function such as HLT, NOP, and EI etc.