1.
Statement: Write an ALP using 8085 to evaluate the expression C=A +B
2 2
Let ‘A’ be Data#1 and ‘B’ be Data#2
Source program 1:
MVI B, Data#1 ; Data #1 is stored in register B
MOV C, B ; Copy of Data #1 is made in register C
MVI D, Data#2 ; Data #2 is stored in register D
MOV E,D ; Copy of Data #2 is made in register E
XRA A ; Accumulator content is cleared
Again: ADD B ]
DCR C } A2 is calculated by repeated Addition
JNZ Again ]
MOV H,A ; Calculated A2 value is stored in register H
XRA A ; Accumulator content is cleared
Loop: ADD D ]
DCR E } B2 is calculated by repeated Addition
JNZ Loop ]
ADD H ; A2+ B2 is determined, by adding result in A and register content H
STA 4200H ; Result is stored in memory location 4200H
4. Calculate the sum of series of numbers(8085)
Statement: Calculate the sum of series of numbers. The length of the series is
in memory location 4200H and the series begins from memory location 4201H.
a. Consider the sum to be 8 bit number. So, ignore carries. Store the sum at
memory location 4300H.
b. Consider the sum to be 16 bit number. Store the sum at memory locations
4300H and 4301H.
a. Sample problem
4200H = 04H
4201H = 10H
4202H = 45H
4203H = 33H
4204H = 22H
Result = 10 +41 + 30 + 12 = H
4300H = H
Source program:
LDA 4200H
MOV C, A : Initialize counter
SUB A : sum = 0
LXI H, 420lH : Initialize pointer
BACK: ADD M : SUM = SUM + data
INX H : increment pointer
DCR C : Decrement counter
JNZ BACK : if counter 0 repeat
STA 4300H : Store sum
HLT : Terminate program execution
b. Sample problem
4200H = 04H
420lH = 9AH
4202H = 52H
4203H = 89H
4204H = 3EH
Result = 9AH + 52H + 89H + 3EH = H
4300H = B3H Lower byte
4301H = 0lH Higher byte
Source program:
LDA 4200H
MOV C, A : Initialize counter
LXI H, 4201H : Initialize pointer
SUB A :Sum low = 0
MOV B, A : Sum high = 0
BACK: ADD M : Sum = sum + data
JNC SKIP
INR B : Add carry to MSB of SUM
SKIP: INX H : Increment pointer
DCR C : Decrement counter
JNZ BACK : Check if counter 0 repeat
STA 4300H : Store lower byte
MOV A, B
STA 4301H : Store higher byte
HLT :Terminate program execution
5. Statement:Divide 16 bit number stored in memory locations 2200H and 2201H by the
8 bit number stored at memory location 2202H. Store the quotient in memory locations
2300H and 2301H and remainder in memory locations 2302H and 2303H.
Sample problem
(2200H) = 60H
(2201H) = A0H
(2202H) = l2H
Result = A060H/12H = 8E8H Quotient
and 10H remainder
(2300H) = E8H
(2301H) = 08H
(2302H= 10H
(2303H) 00H
Source program
LHLD 2200H : Get the dividend
LDA 2202H : Get the divisor
MOV C, A
LXI D, 0000H : Quotient = 0
BACK: MOV A, L
SUB C : Subtract divisor
MOV L, A : Save partial result
JNC SKIP : if CY 1 jump
DCR H : Subtract borrow of previous
subtraction
SKIP: INX D : Increment quotient
MOV A, H
CPI, 00 : Check if dividend < divisor
JNZ BACK : if no repeat
MOV A, L
CMP C
JNC BACK
SHLD 2302H : Store the remainder
XCHG
SHLD 2300H : Store the quotient
HLT : Terminate program
execution
6. Count number of one's in a number (8085)
Statement:Write a program to count number of l's in the contents
of D register and store the count in the B register.
Source program:
MVI B, 00H
MVI C, 08H
MOV A, D
BACK: RAR
JNC SKIP
INR B
SKIP: DCR C
JNZ BACK
HLT
8. Statement: Calculate the sum of series of odd numbers from the list of numbers. The length
of the list is in memory location 2200H and the series itself begins from memory location 2201H.
Assume the sum to be 16-bit. Store the sum at memory locations 2300H and 2301H.
Sample problem 1:
2200H = 4H
2201H= 9AH
2202H= 52H
2203H= 89H
2204H= 3FH
Result = 89H + 3FH = C8H
2300H= H Lower byte
2301H = H Higher byte
LDA 2200H
MOV C, A : Initialize counter
MVI B, 00H : sum = 0
LXI H, 2201H : Initialize pointer
BACK: MOV A, M : Get the number
ANI 0lH : Mask Bit l to Bit7
JNZ SKIP : Don't add if number is ODD
MOV A, B : Get the sum
ADD M : SUM = SUM + data
MOV B, A : Store result in B register
SKIP: INX H : increment pointer
DCR C : Decrement counter
JNZ BACK : if counter 0 repeat
STA 2210H : store sum
HLT : Terminate program execution
10. Find the square of given number (8085)
Statement:Find the square of the given numbers from memory location 6100H and store the result from memory
location 7000H.
Source Program:
LXI H, 6200H : Initialize lookup table pointer
LXI D, 6100H : Initialize source memory pointer
LXI B, 7000H : Initialize destination memory pointer
BACK: LDAX D : Get the number
MOV L, A : A point to the square
MOV A, M : Get the square
STAX B : Store the result at destination memory location
INX D : Increment source memory pointer
INX B : Increment destination memory pointer
MOV A, C
CPI 05H : Check for last number
JNZ BACK : If not repeat
HLT : Terminate program execution
11.Arrange in DESCENDING Order (8085)
Statement: Arrange an array of 8 bit unsigned no in descending order
Source Program:
START:MVI B, 00 ; Flag = 0
LXI H, 4150 ; Count = length of array
MOV C, M
DCR C ; No. of pair = count -1
INX H ; Point to start of array
LOOP:MOV A, M ; Get kth element
INX H
CMP M ; Compare to (K+1) th element
JNC LOOP 1 ; No interchange if kth >= (k+1) th
MOV D, M ; Interchange if out of order
MOV M, A ;
DCR H
MOV M, D
INX H
MVI B, 01H ; Flag=1
LOOP 1:DCR C ; count down
JNZ LOOP ;
DCR B ; is flag = 1?
JZ START ; do another sort, if yes
HLT ; If flag = 0, step execution
12. Statement: Convert a 2-digit BCD number stored at memory address 2200H into its binary
equivalent number and store the result in a memory location 2300H.
Sample problem 1:
(2200H) = 67H
(2300H) = 6 x OAH + 7 = 3CH + 7 = 43H
Flowchart for program
Source program :
LDA 2200H : Get the BCD number
MOV B, A : Save it
ANI OFH : Mask most significant four bits
MOV C, A : Save unpacked BCDI in C register
MOV A, B : Get BCD again
ANI FOH : Mask least significant four bits
RRC : Convert most significant four bits into unpacked
BCD2
RRC
RRC
RRC
MOV B, A : Save unpacked BCD2 in B register
XRA A : Clear accumulator (sum = 0)
MVI D, 0AH : Set D as a multiplier of 10
Sum: ADD D : Add 10 until (B) = 0
DCR B : Decrement BCD2 by one
JNZ SUM : Is multiplication complete? i if not, go back
and add again
ADD C : Add BCD1
STA 2300H : Store the result
HLT : Terminate program execution
13. Statement: Write an assembly language program to convert the contents of the five
memory locations
starting from 2000H
into an ASCII
character. Place the
result in another five
memory locations
starting from 2200H.
Sample
problem :
(2000H) = 1
(2001H) = 2
(2002H) = 9
(2003H) = A
(2004H) = B
Result:(2200H) = 31
(2201H) = 32
(2202H) = 39
(2203H) = 41
(2204H) = 42
Source program :
LXI SP, 27FFH : Initialize stack pointer
LXI H, 2000H : Source memory pointer
LXI D, 2200H : Destination memory pointer
MVI C, O5H : Initialize the counter
BACK: MOV A, M : Get the number
CALL ASCII : Call subroutine ASCII
STAX D : Store result
INX H : Increment source memory pointer
INX D : Increment destination memory pointer
DCR C : Decrement count by 1
CJNZ : if not zero, repeat
HLT : Stop program execution subroutine ASCII
ASCII: CPI, OAH : Check if number is OAR
JNC NEXT : If yes go to next otherwise continue
ADI 30H
JMP LAST
NEXT: ADI 37H
LAST: RET : Return to main program
Subroutine:
Subroutine 'ASCII' converts a hexadecimal digit to ASCII.The digit is
passed using accumulator and the result is stored in accumulator.Stack
starts From 27FEH to 27FDH.
Note: The ASCII Code (American Standard Code for Information Interchange) is commonly used
for communication. In such cases we need to convert binary number to its ASCII equivalent. It is a
seven bit code. In this code number 0 through 9 are represented as 30 through 39 respectively and
letters A through Z are represented as 41H through 5AH. Therefore, by adding 30H we can convert
number into its ASCII equivalent and by adding 37H we can convert letter to its ASCII equivalent.
14. HEX to binary conversion(8085)
Statement: Convert an 8 bit hex no to its binary form & store in memory.
Source Program:
LXI H, 4150 : Initialize memory pointer
MVI B, 08 : count for 8-bit
MVI A, 54
LOOP : RRC
JC LOOP1
MVI M, 00 : store zero it no carry
JMP COMMON
LOOP2: MVI M, 01 : store one if there is a carry
COMMON: INX H
DCR B : check for carry
JNZ LOOP
HLT : Terminate the program
15. Stepper Motor Control
Statement: Interface a Stepper Motor to the
8085 microprocessor system and write an 8085
assembly language program to control the
Stepper Motor
HARDWARE FOR STEPPER MOTOR CONTROL
motor is a digital motor. It can be driven by
digital signal. Fig. shows the typical 2 phase
motor rated 12V /0.67 A/ph interfaced with the
8085 microprocessor system using 8255. Motor
shown in the circuit has two phases, with center-
tap winding. The center taps of these windings
are connected to the 12V supply. Due to this,
motor can be excited by grounding four
terminals of the two windings. Motor can be
rotated in steps by giving proper excitation sequence to these windings. The lower nibble of port A of the
8255 is used to generate excitation signals in the proper sequence. These excitation signals are buffered
using driver transistors. The transistors are selected such that they can source rated current for the
windings. Motor is rotated by 1.80 per excitation
SOFTWARE FOR STEPPER MOTOR CONTROL
As port A is used as an output port, control word for 8255 is 80H.
Stepper Motor Control Program:
6000H Excite code DB 03H, 06H,
09H, OCH : This is the code sequence for clockwise rotation
Subroutine to rotate a stepper motor clockwise by 360° - Set the counts:
MVI C, 32H : Set repetition count to 50ıο
START: MVI B, 04H : Counts excitation sequence
LXI H, 6000H : Initialize pointer
BACK1: MOV A, M : Get the Excite code
OUT PORTA : Send Excite code
CALL DELAY : Wait
INX H : Increment pointer
DCR B : Repeat 4 times
JNZ BACK l
DCR C
JNZ START : Repeat 50 times
RET
INTERFACING SCHEME
Delay subroutine:
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
16. Statement: Design a microprocessor system to control traffic lights. The traffic light
arrangement is as shown in Fig. The traffic should be controlled in the following manner.
1) Allow traffic from W to E and E to W transition for 20 seconds. 2) Give transition period of 5
seconds (Yellow bulbs ON) 3) Allow traffic from N to 5 and 5 to N for 20 seconds 4) Give transition
period of 5 seconds (Yellow bulbs ON) 5) Repeat the process.
HARDWARE FOR TRAFFIC LIGHT CONTROL
Fig. shows the interfacing diagram to control 12 electric bulbs.
Port A is used to control lights on N-S road and Port B is used
to control lights on W-E road. Actual pin connections are listed
in Table 1 below.
The electric bulbs are controlled by relays. The 8255
pins are used to control relay on-off action with the
help of relay driver circuits. The driver circuit
includes 12 transistors to drive 12 relays. Fig. also
shows the interfacing of 8255 to the system.
INTERFACING DIAGRAM
SOFTWARE FOR TRAFFIC LIGHT CONTROL
Source Program 1:
MVI A, 80H : Initialize 8255, port A and port B
OUT 83H (CR) : in output mode
START: MVI A, 09H
OUT 80H (PA) : Send data on PA to glow R1 and R2
MVI A, 24H
OUT 81H (PB) : Send data on PB to glow G3 and G4
MVI C, 28H : Load multiplier count (40ıο) for delay
CALL DELAY : Call delay subroutine
MVI A, 12H
OUT (81H) PA : Send data on Port A to glow Y1 and Y2
OUT (81H) PB : Send data on port B to glow Y3 and Y4
MVI C, 0AH : Load multiplier count (10ıο) for delay
CALL: DELAY : Call delay subroutine
MVI A, 24H
OUT (80H) PA : Send data on port A to glow G1 and G2
MVI A, 09H
OUT (81H) PB : Send data on port B to glow R3 and R4
MVI C, 28H : Load multiplier count (40ıο) for delay
CALL DELAY : Call delay subroutine
MVI A, 12H
OUT PA : Send data on port A to glow Y1 and Y2
OUT PB : Send data on port B to glow Y3 and Y4
MVI C, 0AH : Load multiplier count (10ıο) for delay
CALL DELAY : Call delay subroutine
JMP START
Delay Subroutine:
DELAY: LXI D, Count : Load count to give 0.5 sec delay
BACK: DCX D : Decrement counter
MOV A, D
ORA E : Check whether count is 0
JNZ BACK : If not zero, repeat
DCR C : Check if multiplier zero, otherwise repeat
JNZ DELAY
RET : Return to main program
** Extra program which I found :
Statement: Calculate the sum of series of even numbers from the list of numbers. The length of
the list is in memory location 2200H and the series itself begins from memory location 2201H.
Assume the sum to be 8 bit number so you can ignore carries and store the sum at memory location
2210H.
Sample problem 1:
2200H= 4H
2201H= 20H
2202H= l5H
2203H= l3H
2204H= 22H
Result 22l0H= 20 + 22 = 42H
= 42H
Flowchart for program
Source program :
LDA 2200H
MOV C, A : Initialize counter
MVI B, 00H : sum = 0
LXI H, 2201H : Initialize pointer
BACK: MOV A, M : Get the number
ANI 0lH : Mask Bit l to Bit7
JNZ SKIP : Don't add if number is
ODD
MOV A, B : Get the sum
ADD M : SUM = SUM + data
MOV B, A :
Store result in B register
SKIP: INX H : increment pointer
DCR C : Decrement counter
JNZ BACK : if counter 0 repeat
STA 2210H : store sum
HLT : Terminate program execution