0% found this document useful (0 votes)
42 views27 pages

Unit 2 (Upto Midsem)

Uploaded by

zufishan66
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)
42 views27 pages

Unit 2 (Upto Midsem)

Uploaded by

zufishan66
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/ 27

FUNDAMENTALS OF MICROPROCESSOR

UNIT 2
programmINg The 8085

By:
ATIFA AQUEEL
Electronics Engg. Section
University Women’s Polytechnic, AMU
SyllabUS
I. INTRODUCTION TO THE INTEL 8085
• Definition of microprocessor, generations and types of microprocessors,
most popular microprocessors.
• Architecture of 8085, brief description of ALU, register section, data &
address buses. Bus time sharing 8085 CPU pins and associated signal.
II. PROGRAMMING THE 8085
• Instruction, Group of instruction, Addressing modes of Instruction, 8085
instruction set. Machine Language, Assembly Language comparison,
Assembly Language programming (Simple Problems).
III. TIMING INSTRUCTION & EXECUTION
• Machine, Instruction, Fetch, Read, Write(IO/MEM) cycle timing diagram,
Interruption: Types of 8085 interrupt system, 8085 SID and SOD lines.

29-09-2022 By: Atifa Aqueel 2


SyllabUS
IV. PERIPHERAL INTERFACING
• PPLD’S, Brief description of 8255, 8257-DMA Controller, Introduction to
Intel’s 8086 microprocessor, Popular applications of Microprocessor in
industry.
BOOKS RECOMMENDED:-
1. Microprocessor Architecture, Programming & Applications, by Goankar,
6th Edition 2013
2. Fundamentals of Microprocessor and Microcontrollers, by B.Ram,
Dhanpat Rai Publications, 9th edition 2019.
3. Microprocessor and Microcomputers by Rafiquzzaman, Universal Book
Stall (UBS Pub.) 1997
4. Introduction to Microprocessor, by Mathur, 3rd Edition 1997, Aditya P
Mathur (Tata McGraw Hill, Pub. Co.Ltd)

29-09-2022 By: Atifa Aqueel 3


INSTRUCTION

29-09-2022 By: Atifa Aqueel 4


Opcodes and Operands

29-09-2022 By: Atifa Aqueel 5


Data Transfer Group

• For e.g.
1. MOV A,B : Move the content of reg B to reg A
2. MVI A, 25H : Move 25H to accumulator (Reg A)
3. LDA 2000H : Load the accumulator with the content present in memory
location 2000H.
4. LXI B, 2020H: Load the register pair BC with the content present in
memory location 2020H and 2021H. (X: Reg pair …16 bits)
29-09-2022 By: Atifa Aqueel 6
Arithmetic Group

• For e.g.
1. ADD B:
2. SUB C:
3. INR A:
4. DCR C:

29-09-2022 By: Atifa Aqueel 7


Other 3 Groups

29-09-2022 By: Atifa Aqueel 8


Instruction Word Size

29-09-2022 By: Atifa Aqueel 9


One Byte Instruction
• The instruction which has only one part i.e. opcodes is known as one byte
instruction. In other words one byte instructions include the opcode and
operand in the same byte and it is stored in only one memory location.

29-09-2022 By: Atifa Aqueel 10


Two-Byte Instruction
• In two byte instruction , the first byte is in its operand and the second byte
is either 8-bit data or address. For Example:

29-09-2022 By: Atifa Aqueel 11


Three Byte Instruction

29-09-2022 By: Atifa Aqueel 12


Q: Write the size of the following
instructions
1. SUB B
2. INR B
3. MVI B,25H
4. LXI D, 2500H
5. MOV M, A
6. SBI 38H
7. INX H
8. DCR D
9. CMA
10. RAL
11. LHLD 3000H

29-09-2022 By: Atifa Aqueel 13


Instruction and Data Formats
• The various techniques to specify data for instructions are:
1. 8-bit or 16-bit data may be directly given in the instruction itself.
2. The address of the memory location, I/O port or I/O device, where data
resides, may be given in the instruction itself.
3. In some instructions, only one register is specified. The content of the
specified register is one of the operands.
4. Some instructions specify two registers. The contents of the registers are
the required data.
5. In some instructions, data is implied. The most instructions of this type
operate on the content of the accumulator.
• Due to different ways of specifying data for instructions, the machine codes
of all instructions are not of the same length. It may 1-byte, 2-byte or 3-
byte instruction.

29-09-2022 By: Atifa Aqueel 14


8085 Addressing Modes
• The manner in which an operand is given in an instruction is known as
Addressing Mode.
• Each instruction requires certain data on which it has to operate.
• The different technique by which the microprocessor specifies the operand
in an instruction is known as addressing mode.
• Intel 8085 supports the following addressing modes:

1. Immediate Addressing Modes


2. Register Addressing Modes
3. Direct Addressing Modes
4. Indirect Addressing Modes
5. Implicit Addressing Modes

29-09-2022 By: Atifa Aqueel 15


Immediate Addressing Mode
• In this mode, the 8/16-bit operand (data/address) is specified in the
instruction itself as one of its operand.
• In this mode, the number directly given by the programmer is moved into
the location specified. This location could be a register or an address in the
memory.
• In other words, we can understand the Immediate Addressing Mode as a
mode in which an immediate value is given to operate on.
• For Example:
1. MVI A, 25H ; Save 25H into the Accumulator
2. MVI C, 62H ; Save 62H into the C register
3. LXI B, 3050H ;Load B-C pair with value 3050H.
4. ADI 20H ;The value 20H is added to the contents of the accumulator.
5. SUI 22H ;The value 22H is subtracted from the contents of the accumulator

29-09-2022 By: Atifa Aqueel 16


Immediate Addressing Mode
• Some other examples are:
1. LXI H, 3050H ;Load H-L pair with value 3050H. Higher byte 30H goes
in H while lower byte 50H goes in L
2. LXI SP, 4050H ;Load value 4050H in stack pointer register
3. JMP 9000H ;Jump to address 9000H.

• Note: These instructions may seem to be too many. But you can simply
remember them as “The instructions ending with the letter I, which stands
for immediate, are the instructions for immediate addressing mode” with
one exception though: the JMP instruction.

29-09-2022 By: Atifa Aqueel 17


Register Addressing Mode
• In register addressing mode the operand is in one of the general purpose
registers.
• The opcode specifies the address of the register in addition to the operation
to be performed.
• In this mode, the data to be accessed and operated upon is present in a
register and is accessed by specifying the name of the register.
• For Example:
1. MOV A, B ;Save contents of B in Accumulator
• This command moves the contents stored inside the B register to the
Accumulator.
2. ADD B ;Adds the value stored in B to the value in Accum.
3. SUB E ;Subtracts the value stored in E to that in Accum.
4. INR C ;Increments the contents of register C by 1
5. INX B ;Increments the contents of register pair BC by 1

29-09-2022 By: Atifa Aqueel 18


Direct Addressing Mode
• In this mode, the address of the operand is specified in the instruction itself.
• For example LDA 3000H: means the data at address 3000H is copied to
register A.
• In other words, we access the data stored in a memory location using its
address. Consider the example
1. LDA 2034H ;Load the content at memory location 2034H into the
Accumulator
2. LHLD 2040H ;Load the content at 2040H into register L and contents at
the next location 2041H into register H
3. STA 3030H ;Load the content at memory location 3030H into the
Accumulator
4. SHLD 2040H ;Load the contents of the register L into memory location
with address 2040H and load the ;contents of register H at the next
memory location 2041H
29-09-2022 By: Atifa Aqueel 19
Memory Label Mnemonics/ Opcode Comments
Address Opcodes
2000 MVI C, 00H 0E, 00 Clear Register C
2002 MVI A, 98H 3E, 98 Move 99H in Accumulator
2004 MVI B, 98H 06, 98 Move 98H in Register B
2006 ADD B 80 Add the content of A and B and store
the result in A
2007 JNC 200B D2, 0B, 20 Jump to AHEAD if CY = 0
200A INRC 0C If CY=1, increment Reg C by 1, C=1
200B AHEAD: STA 2503H 32, 03,25 Store the result (Accum) in 2503H
200E MOV A,C 79 Move content of C (i.e. Carry) in
Accum.
200F STA 2504H 32, 04, 25 Store the Carry (Accum) in 2504H
2012 RST 5 EF Reset the processor

29-09-2022 By: Atifa Aqueel 20


Register Indirect Addressing Mode
• In this mode, the register(s) holds the address of the location from which
data is to be retrieved.
• Here the address of the operand is specified in a register pair, Hence this
type of instructions indirectly point to the operand.
• MOV A, M ;move contents of the memory location whose address is held
by HL pair into the Accumulator.

29-09-2022 By: Atifa Aqueel 21


Example
• Consider the following lines of instructions.
• Suppose it is known that the number 25H is stored at memory location with
address 2030H and the programmer wants to transfer that data to
accumulator.
• MVI H, 20H
OR LXI H, 2030H
• MVI L, 30H
• MOV A, M ;M stands for memory (i.e HL pair)
• MVI M, 92H

29-09-2022 By: Atifa Aqueel 22


Explanation
1. After the execution of the first line, register H will have value 20H stored in it.
2. After the execution of the second line, register L will have value 30H stored in
it. So, now we have 2030H stored in register pair HL.
3. The instruction in the third line tells the microprocessor to look at the address
(in the memory) given by the HL pair which is now 2030H. So, the
microprocessor looks at the location with address 2030H and loads the content
stored there into the accumulator. As we assumed, the memory location with
address 2030H had the number 25H stored in it. So, the microprocessor will
copy it and paste it in the accumulator. And hence, the accumulator will
contain 25H.
4. In the fourth line of instruction, we tell the microprocessor to move the value
given by us, i.e. 92H to the memory location. And the address of the memory
location is read from the HL register pair. HL pair still holds the value 2030H.
So, the microprocessor will store 25H at the memory location with address
2030H.
5. So, in the end, the Accumulator will hold the value 25H and the memory
location with address 2030H will hold the value 92H.
29-09-2022 By: Atifa Aqueel 23
Register Indirect Addressing Mode
• A very important point to note here is that the address of a memory location
is of 16-bit size but the data stored in a single memory location is 8 bits.
• Some more instructions which use this mode of addressing.
1. ADD M ;Add contents of the memory location whose address is held by HL
pair to the contents of theAccumulator
2. INR M ;Add contents of the memory location whose address is held by HL
pair is incremented by 1
3. CMP M ;16 bit number from HL pair is picked up. Then, contents at the
address given by picked up number is ;compared with those of the
accumulator.
• The result of the comparison is shown by setting the flags of ;the PSW as
follows: ;
• * if (A) < (reg/mem): carry flag is set ;
• * if (A) = (reg/mem): zero flag is set ;
• * if (A) > (reg/mem): carry and zero flags are reset

29-09-2022 By: Atifa Aqueel 24


Implied Addressing Mode
• In this mode of addressing, the microprocessor already knows the location
of data to process and the programmer does not need to define it explicitly.
That information is already contained in the opcode.
• For example,
1. CMA ; Each bit of the 8 bit number stored in Accumulator is
complemented. Note that in this case, it is implied ; that the data to be
processed is in the accumulator and we don't need to specify it.
2. RLC ; the 8 bits of the number stored in the Accumulator are manipulated
in such a way that each bit is moved ; left by 1 place and the most
significant bit is moved to the least significant position.
3. CMC ; The carry flag is complemented
4. STA ; The carry flag is set to 1
• The address of data to be manipulated is the register A which is not stated
in the instruction. It is already understood by the microprocessor when such
instructions (instructions with implied addressing mode) are used.

29-09-2022 By: Atifa Aqueel 25


Examples
Q.1: Multiply 1245H by 2 .
Ans: LXI H, 1245H
DAD H
HLT

Q.2: ADD 1245H & 1345H using DAD instruction.


Ans: LXI H, 1245H
LXI B, 1345H
DAD B
HLT
Q.3: ADD two numbers present in memory locations 2501H and 2502H
respectively and store the 8-bit result in 2503H (Use indirect addressing
mode)

29-09-2022 By: Atifa Aqueel 26


DAA Instruction
• DAA: Decimal Adjust Accumulator
• The instruction DAA is used in the program after ADD, ADC, ADI, ACI
etc.
• After ADD, ADC etc. the result is in hexadecimal form and it is placed in
accumulator.
• The DAA instruction operates on this result and gives the final result in
decimal system.
• It uses carry and auxiliary carry for decimal adjustment.
• When the sum lies between 10 to 15 (or A to F hexadecimal) a correction of
+6 is made by DAA instruction. 6 is added to both LSBs and MSBs.
• 6 is added to 4 LSBs of the content of accumulator if the values lie in
between A and F or the auxiliary carry flag is set to 1.
• Similarly,6 is added to 4 MSBs of the content of accumulator if the values
lie in between A and F or the carry flag is set to 1.
• Thus DAA instruction checks whether there is a carry, auxiliary flag or the
sum lies between A to F and makes corrections accordingly.
29-09-2022 By: Atifa Aqueel 27

You might also like