ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPCI4, 3MD Yr. ECE
see LAB MANUAL
INTRODUCTION
Introduction to Microprocessor:
The microprocessor is a clock-driven semiconductor device consisting of electronic logic
circuits manufactured by using cither a large-scale integration (LSI) or very-large-scale
integration (VLSI) techniquc.
The microprocessor is capable of performing various computing functions and making
decisions to change the sequence of program execution. In large computers, a CPU
implemented on one or more circuit boards performs these computing functions.
The microprocessor is in many ways similar to the CPU, but includes all the logic circuitry,
including the control unit, on one chip.
The microprocessor can be divided into three segments for the sake of clarity,
arithmetic/logic unit (ALU), register array, and control unit.
Internal architecturc of 8085 microprocessor :
Soiat :G ont
B-ttotng data buS
Accutaor Temp reg Flag lip-flops nsttuco (8)|C reg
(A eg) 81 egIster (8)
B}
(5)
Stack nta (16)
Piogran countêr .161
tine
rciermenterdoc ternolar
{16)
|Addhe5
buttet
ta CMA He
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3RD Yr. ECE
Cuitute
LAB MANUAL
Incement
and
Of Educ ation
Control Unit
Generates signals within pp to carry out the instruction, which has been decoded. Inreality
causes cetain connetions between blocks of the P to be opened or closed, sothat data
goes where it is required, and so that ALU operations occur.
Arithmetic Logic Unit
The ALU performs the actual numerical and logic operation such as 'add', 'subtract', 'AND',
*OR', etc. Uses data from memory and from Accumulator to perform arithmetic. Always
stores result of operation in Accumulator.
Registers
The 8085/8080A-programming model includes six registers, one accumulator, an done flag
register, as shown in Figure. In addition, it has two 16-bit registers: the stack pointer and
the program counter. They are described briefly as follows. The 8085/8080A has six
general-purpose registers to store 8-bit data, these are identified as B,C,D,E,H, and L as
shown in the figure. They can be combined as register pairs - BC, DE, and HL - to perform
some 16-bit operations. The programmer can use these registers to store or copy data into
the registers by using data copy instructions.
Instruction Register/Decoder
Temporary store for the current instruction of a program. Latest instruction sent here from
memory prior to execution. Decoder then takes instruction and 'decodes' or interprets the
instruction. Decoded instruction then passed to next stage.
Memory Address Register
Holds address, received from PC, of next program instruction. Feeds the address bus with
addresses of location of the program under execution.
Control Generator
Generates signals within uP to carry out the instruction which has been decoded. In reality
causes certain connections between blocks of the pP to be opened or closed, so that data
goes where it is required, and so that ALU operations occur.
Register Selector
This block controls the use of the register stack in the example. Just a logic circuitwhich
switches between different registers in the set will receive instructions fromControl Unit.
2
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROILLER LAB
PAPER CODE: ECEUGPCI4, 3kD Yr. ECE
o na e a C
eement of LAB MANUAL
8085 System Bus
Typical system uses a number of busses, collection of wires, which transnit binary
numbers, one bit per wire. Atypical microprocessor communicates with memory and other
devices (input and output) using three busses: Address Bus, Data Bus and Control Bus.
Address Bus
Address bus is used to select the specific register from a block of registers ie memory.
Address bus is unidirectional, ie. numbers only sent from microprOcessor to memory, not
other way. The 8085 microprocessor contains 16 address lines, so it can address maximum
of 216 =64 KB memory space.
Data Bus
Data Bus carries 'data', in binary form, between uP and other external units, such
asMemory, l/O devices etc. The 8085 microprocessor contains 8 data lines. The Data can
be transferred at both directions ie from microprocessor to external unit or from external unit
to microprocessor so the data bus is bidirectional.
Control Bus
Control Bus are various lines which have specific functions for coordinating and controlling
UP operations such as ReadWrite line. The Control Bus carries control signals, may
unidirectional or bi-directional.
The 8085 Programming Model
The 8085 programming model includes six registers, one accumulator, and one flag
register, as shown in Figure. In addition, it has two 16-bit registers: the stack pointer and
the program counter. They are described briefly as follows.
Registers
The 8085 has six general-purpose registers to store 8-bit data; these are identified as
B,C,D,E,H, and L as shown in the figure. They can be combined as register pairs -BC, DE,
and HL - to perform some 16-bit operations. The programmer can use these registers to
store or copy data into the registers by using data copy instructions.
3
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3RD Yr. ECE
i o n andCa
LAB MANUAL
Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic unit (ALU). This register
is used to store 8-bit data and to perform arithmetic and logical operations. The result of an
operation is stored in the accumulator. The accumulator is also identified as register A.
ACCUNIULATOR A FI AG RFGISTFR
(S (S)
(S E (S)
(S) L (S)
Stack Pointer (SP) (16)
Program Conter (PC) (16)
Data Bus
Addreks Bus
S Lines Bidirecional 16Lines lunidirectional
Flags
The ALU includes five flip-flops, which are set or reset after an operation according to data
conditions of the result in the accumulator and other registers. They are called Zero (Z),
Carry (CY),Sign (S), Parity (P), and Auxiliary Carry (AC) flags; their bit positions in the flag
register are shown in the Figure below. The most commonly used flags are Zero, Carry,.
and Sign. The microprocessor uses these flags to test data conditions.
D D6 Ds D: D; D: D1 Do
AC P
4
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
Cultute PAPER CODE: ECEUGPC14, 3RD Yr. ECE
n andC
Edueation LAB MANUAL
Program Counter (PC)
This 16-bit register deals with sequencing the execution of instructions. This register is a
memory pointer. Memory locations have 16-bit addresses, and that is why this is a16-bit
register.
The microprocessor uses this register to sequence the execution the instructions. The
function of the program counter is to point to the memory address from which the next byte
is to be fetched. When a byte (machine code) is being fetched, the program counter is
incremented by one to point to the next memory location
Stack Pointer (SP)
The stack pointer is also a 16-bit register used as a mnemory pointer. lt points a memory
location in RW memory, called the stack. The beginning of the stack is defined by loading
16-bit address in the stack pointer.
ALIAH UNIVERSITY
MICROCONTROLLER LAB
MICROPROCESSOR &
Yr. ECE
PAPER CODE: ECEUGPC14, 3D
Cut
nd
LAB MANUAL
t i o r
Educ
Instruction set of 8085 Microprocessor
STUDY OF DATA TRANSFER INSTRUCTIONS
MOV Copy from source to destination
MVI Move immediate 8-bit
LDA Load acCumulator
LDAX Load acCumulator indirect
LXI Load register pair immediate
LHLD Load H and L registers direct
STA Store accumulator direct
STAX Store accumulator indirect
SHLD Store Hand L registers direct
XCHG Exchange H and L with D and E
SPHL Copy H and L registers to the stack pointer
XTHL Exchange H and L with top of stack
PUSH Push register pair onto stack
POP Pop of stack to register pair
OUT Qutput data from accumulator to a port with 8-bit address
IN Input data to accumulator froma port with 8-bit address
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 34D Yr. ECE
Cutu
and
OEduC atiot! LAB MANUAL
STUDY OF ARITHMETIC AND LOGICAL INSTRUCTIONS
ADD Add register or memory to accumulator
ADC Add register to accumulator with carry
ADI Add immediate to accumulator
ACI Add immediate to accumulator with carry
DAD Add register pair to H and L registers
SUB Subtract register or memory from accumulator
SBB Subtract source and borrow from accumulator
SUI Subtract immediate from accumulator
SBI Subtract immediate from accumulator with borrow
INR Increment register or memory by 1
INX Increment register pair by 1
DCR Decrement register or memory by 1
DCX Decrement register pair by 1
DAA Decimal adjust accumulator
CMP Compare register or mernory with accumulator
CPI Compare immediate with accumulator
ANA Logical AND register or memory with accumulator
ANI Logical AND immediate with accumulator
XRA Exclusive OR register or memory with accumulator
XRI Exclusive OR immediate with accumulator
ORA Logical OR register or memory with accumulator
ORI Logical OR immediate with accumulator
RLC Rotate accumulator left
RRC Rotate accumulator right
RAL Rotate accumulator left through carry
RAR Rotate accumulator right through carry
CMA Complement accumulator
CMC Complement carry
STC Set carry
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3RD Yr. ECE
LAB MANUAL
eement etion and
of Educ a
STUDY OF BRANCHING INSTRUCTIONS
JMP Jump unconditionally
JC Jump on carry
JNC Jump on no carry
JP Jump on positive
JM Jump on minus
JZ Jump on zero
JNZ Jump on no zero
JPE Jump on parity even
JPO Jump on parity odd
CALL Call unconditionally
CC Call on carry
CNC Call on no carry
CP Call on positive
CM Call on minus
CZ Call on zero
CNZ Call on no zerO
CPE Call on parity even
CPO Call on parity odd
RET Return unconditionally
RC Return on carry
RNC Return on no carry
RP Return on positive
RM Return on minus
RZ Return on zerO
RNZ Return on no zero
RPE Return on parity even
RPO Return on parity odd
PCHL Load program counter with HL contents
RST Restart
8
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPERCODE:ECEUGPCI4, 3RD Yr. E.CE
Cu
nceme
and
LAB MANUAL
Of Educ ation
Familiarization with the 8085 trainer kit.
PROCEDURE FOR STORINGA PROGRAM
1. Press RESET. The display should show SDA-8085-STA.
2. Then press A to use the Assembler.
3. Select the starting address of the program and press NEXT (,)
4. Write the instruction and press ENTER.
5. Note down the opcode and press ENTER.
6. Write the next instruction and follow steps 4 and 5.
7. After the last instruction has been stored press ESC to come out of the assembly
mode.
8. The display should show SDA-8085-STA.
SDg-8085-S79
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3RD Yr. ECE
LAB MANUAL
PROCEDURE FOR EXECUTING A PROGRAM
1. Press GO (G).
2. Type the staring address of the program.
3. Press ENTER. The display should show SDA-8085-STA if properly executed.
PROCEDURE FOR STORING OR CHECHING DATASTORED IN MEMORY.
1. Press M.
2. Now type the address of the memory location that is to be used.
3. Press NEXT (,).
4. The data that is being shown is the current data. If data is to be modified type the
new data,
5. Press NEXT ).
6. The data in the next location is being shown.
PROCEDURE FOR CHECHING DATA STORED INA REGISTER
1. Press X. The display shows which register?
2. Type the name of the register whose data is to be checked.
3. Press NEXT (,) to check the next register.
10
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3kD Yr. ECE
Ctu
ane a n d
LAB MANUAL
Pent of Educalion
ASSIGNMENT -1
1. Introduction with the trainer kit.
2. Write a program to store 90h in accumulator. Then transfer its content to reg. C and
to memory location 8500h using direct addressing. Also transfer the content of reg. C
to memory location 8600h using indirect addressing.
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPCI4, 3kD Yr. KCE
Cultue
avanceCement Euucation
ndo LAB MANUAL
ofy
ASSIGNMENT -2
1. Write a program to add a number which is stored in memory location 8200, with
another number which is stored in memory location 8300,.Store the result from
8500n,
2. Write a program to subtract a number which is stored in memory location 8200,
from a number which is stored in memory location 8300h.Store the difference in
8500h and the borrow in 8501 h.Use
. SUB instruction
" 2's complement method. CavrY
6A
82004
1 ooH
12
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3RD Yr. ECE
nandCultute
Cemeent of Educato LAB MANUAIL
ASSIGNMENT -3
1. The memory location 8500, and8501h Contain two numbers. Find
a. Logical OR of the two numbers and store in 8600,.
b. Logical XOR of the two numbers and store in 8601 h
C. Logical AND of the twO numbers and store in 8602h
2, Write a program for the addition of 10 numbers stored in successive memory
locations starting from 8100n. Store the result in 8200, and 8201h.
3. Eight BCD numbers are stored in consecutive memory locations starting from 8500h.
Write a program to add them and store the result in 8600h and 8601h.
i ts
,
A,
lo ADD
809,o A,873 - kali(o)
1NRC
DCK
3NZ katd()
etA,
STA 8200 H
A, C
STA &21
13
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3D Yr. ECE
LAB MANUAL
e
netPnt of E
Educatiot
ASSIGNMENT - 4
stored in memory locations 8100On and
1. Find the sum of two 16-bit binary numbers
9000n.
8200h respectively. Save the result from memory location
Using DAD instruction
Without using DAD instruction.
C050,. Transfer the entire block of data
2. Six 8-bit data is stored from memory location
to new memory locations starting from C07On.
Assume that the first byte of both strings
3. Write a program to compare two strings.
starting address of the two strings is
Contain the number of bytes in that string. The
found equal place 11n in memory
9000h and 9100n respectively. If both strings are
location 9500h else place 22h.
14
ALIAH UNIVERSITY
MICROPROCESSOR& MICROCONTROLILER LAB
PAPER CODE: ECEUGPC14, 3RD Yr. ECE
Cultut
nt of
Edueatio"and LAB MANUAL
ASSIGNMENT -5
1. Two numbersP and Q are stored in memory locations 9500n and 9600,. Write a
program for the multiplication of the two numbers. Store the result from memory
location 9700h.
2. Two numbers P and Q are stored in memory locations 9500h and 9600h. Find P÷Q.
Store the quotient in 8500h and the remainder 8501h.
3. Calculate the square of the content of memory location 8100, using a Look-up-table
and place the result in 8101h. The look-up table is given below:
Address Data
8200h 00
8201h 01
8201n 04
8206h 36
8209h 81
15
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3D Yr. ECE
andCuitute
LAB MANUAL
ement of! Education
ASSIGNMENT - 6
location 8200n
program to convert a hexadecimal number stored in memory
1. Write a
from 8300.
to its corresponding ASCII. Store the result
2. Fibonacci series is defined as:
1
F(i) = F(i-1) + F(i-2); for all i >2 with F(1) = F(2) =
Store the result in
Write a program to generate the first 10 elements of this series.
consecutive memory locations starting from 9000n.
positive and negative numbers from a series
3. Write a program to find the number of
8400h and the value of N is available at 8500.
of N data bytes. The series starts from
Store the number of positive and negative numbers in 8600n and 8601h respectively.
16
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3RD Yr. ECE
LAB MANUAL
C u l t o
Cemehent
a n d
ofEducation
ASSIGNMENT -7
even numbers in a series of N data bytes.
1. Write a program to separate the odd and
of N is available at 8300h. Store the odd
The series starts from 8200, and the value
numbers from 8400, and the even numbers from 8500h.
locations starting from 8001n and the
2. N numbers are stored in consecutive memory
value of N is available at 8000,Write a program to find the
Maximum of the N numbers.
Minimum of the N numbers.
starting from 8001h and the
3. N numbers are stored in consecutive memory locations
value of N is available at 8000,Write a program to arrange them in
Ascending order
Descending order
17
ALIAH UNIVERSITY
MICROPROCESSOR & MICROCONTROLLER LAB
PAPER CODE: ECEUGPC14, 3kD Yr. ECE
t u t
a n dCullb
LAB MANUAL
ncemehent of Education
ASSIGNMENT -8
a program to generate the
1. Interface an 8-bit DAC with 8085 using 8255. Write
following waveforms:
Square
Sawtooth
Triangular.
case.
Observe the waveform on CRO and note the frequency in each
to read an analog
2. Interface an 8-bit ADC with 8085 using 8255. Write a program
signal using the ADC and store it in memory location 8500h.
18