Statement:: Write An ALP Using 8085 To Evaluate The Expression C A +B
Statement:: Write An ALP Using 8085 To Evaluate The Expression C A +B
Again: ADD B ]
JNZ Again ]
Loop: ADD D ]
JNZ Loop ]
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
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
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
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
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
13. Statement: Write an assembly language program to convert the contents of the five
memory locations
into an ASCII
memory locations
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 :
Subroutine:
Source Program:
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
in Table 1 below.
INTERFACING DIAGRAM
SOFTWARE FOR TRAFFIC LIGHT CONTROL
Source Program 1:
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
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
= 42H
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