Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Experiment No.

: 9
9.Write an assembly program to multiply two 8 bit numbers whose result
is of 16 bits.

The 8085 has no multiplication operation. To get the result of multiplication, we


should use the repetitive addition method. After multiplying two 8-bit numbers
it generate 2-byte numbers, so we are using two registers to hold the result. We
are saving the data at location 8000H and 8001H. The result is stored at location
8050H and 8051H.
Flow Diagram-:
Program Algorithm
LXI H,8000H : Load first operand address
MOV B, M : Store first operand to B
INX H : Increase HL pair
XRA A : Clear accumulator
MOV C, A : Store 00H at register C
LOOP:ADD M : Add memory element with Acc
JNC SKIP : When Carry flag is 0, skip next task
INR C : Increase C when carry is 1
SKIP: DCR B : Decrease B register
JNZ LOOP : Jump to loop when Z flag is not 1
LXI H,8050H : Load Destination address
MOV M, C : Store C register content into
memory
INX H : Increase HL Pair
MOV M, A : Store Acc content to memory
HLT :Terminate the program

Result-:

(8000H) = DCH
(8001H) = ACH
Result = DC * AC = 93D0H

Contents of Flag Register -:


Experiment No. : 10
10.Write an assembly program to perform division of two 8 bit numbers.

The 8085 has no division operation. To get the result of the division, we should
use the repetitive subtraction method. By using this program, we will get the
quotient and the remainder. 8020H will hold the quotient, and 8021H will hold
the remainder. We are saving the data at location 8000H and 8001H. The result
is storing at location 8050H and 8051H.
Flow Diagram-:
Program Algorithm
START:LXI H,0CH : Load 8-bit dividend in HL register
pair
MVI B,04H : Load divisor in B to perform num1 /
num2
MVI C, 08 : Initialize the counter
UP: DADH : Shifting left by 1 bit HL = HL + HL
MOV A, H : Load H in A
SUB B : perform A = A – B
JC DOWN : If MSB < divisor then shift to left
MOV H, A : If MSB > divisor, store the current
value of A in H
INR L : Tracking quotient
DOWN:DCR C : Decrement the counter
JNZ UP : If not exhausted then go again
SHLD 8020 : Store the result at 8020 H
HLT : Stop

Result-:

Experiment No.:11

11.Write an assembly program to find 2's complement of a 16 bit number.


8085 has an instruction CMA. This instruction complements the content of
Accumulator. For 1's complement CMA instruction is sufficient, and for 2's
complement we have to increase the number by 1 after complementing. For 16-
bit number, we are taking the number into HL pair, but for complementing we
have to copy the numbers to Accumulator from H and L one by one. Then by
INX instruction we will increase HL pair to get 2's complement. We are taking
the number from 8000H and 8001H, and storing the 1's complement at location
8050H and 8051H, and 2's complement to 8052H and 8053H.

Flow Diagram-:
Program Algorithm
LHLD 8000H : Load the number from memory to
HL
MOV A, H : Load the H content to A
CMA : Complement the accumulator
MOV H, A : Replace H with A
MOV A, L : Load the L content to A
CMA : Complement the accumulator
MOV L, A : Replace L with A
SHLD 8050H : Store the 1's complemented result
INX H : Increase HL by 1
SHLD 8052H : Store the 2's complemented result
HLT : Terminate the program

Result-:

(8000H) = DCH
(8001H) = ABH

Contents of Flag Register -:


Experiment No. : 12

12. Write an assembly program to implement a Digital Clock.

In this program we are creating a real time clock using 8085MPU. Here we are
generating 1s delay to update seconds. This clock is 24Hrs clock. We are
initializing the clock from 00:00:00. To display the values into 7-segment
display we have to use some Port ICs and correct configurations. In each 60
seconds the minute field is updated, and in each 60 minutes the hour field is
updated. For decimal update, DAA instruction is used in each increment. We
are storing the hour field into 8008H and minute field is stored at 8007H. The
second value is stored at location 8009H.
Flow Diagram-:
Program Algorithm
BEG: LXI H,0000H : Clear HL with 0000H
HR_MIN:SHLD 8007H : Store HL content at 8007H and
8006H
XRA A : Clear A register
N_SEC: STA 8009H : Store acc content at 8009H
CALL DELAY : Delay for 1 second
LDA 8009H : Load the second value
ADI 01H : Add 01 with Acc
DAA : Adjust decimal
CPI 60H : Compare with 60H
JNZ N_SEC : If Z = 0, jump to N_SEC
LHLD 8007H : Load HL from 8007H
MOV A,L : Load L to A
ADI 01H : Add 01 with A
DAA : Decimal adjust
MOV L,A : Load L from A
CPI 60H : Compare A with 60H
JNZ HR_MIN : If Z = 0, jump to HR_MIN
MVI L,00H : Clear L register
MOV A,H : Load H to A
ADI 01H : Add 01 with A
DAA : Decimal adjust
MOV H,A : Send back A to H
CPI 24H : Compare Hour with 24
JNZ HR_MIN : Jump to HR_MIN if Z = 0
JMP BEG : Jump to Begin
DELAY: MVI C,02H : Initialize Count to 02H
L1: LXI D,FFFFH : Load DE with FFFFH
L2: DCX D : Decrease DE
MOV A,D : Take D to A
ORA E : OR A and E
JNZ L2 : If Z = 0, jump to L2
DCR C : Decrease C by 1
JNZ L1 : Jump to L1, if Z = 0
RET : Return from subroutine
Result-:

The numbers are storing into memory location 8008H – 8007H and 8009H.

Experiment No. :13


13.Write an assembly program which contains a main program and a
conversion subroutine to convert a binary number to its equivalent BCD.

Here we are taking a number from the memory, and initializing it as a counter.
Now in each step of this counter we are incrementing the number by 1, and
adjust the decimal value. By this process we are finding the BCD value of
binary number or hexadecimal number. We can use INR instruction to
increment the counter in this case but this instruction will not affect carry flag,
so for that reason we have used ADI 10H.
Flow Diagram-:
Program Algorithm
LXI H,8000H : Initialize memory pointer
MVI D,00H : Clear D- reg for Most significant
XRA A : Byte
MOV C, M : Clear Accumulator
LOOP:ADI 01H : Get HEX data
DAA : Count the number one by one
JNC SKIP : Adjust for BCD count
INR D : Jump to SKIP
SKIP: DCR C : Increase D
JNZ LOOP : Decrease C register
MOV L, A : Jump to LOOP
MOV H, D : Load the Least Significant Byte
SHLD 8050H :Load the Most Significant Byte
HLT : Store the BCD
: Terminate the program

Experiment No.14

14.Write an assembly program to implement a Hexadecimal up counter.


Hexadecimal counters in 8085 are similar to the binary counter. There are two
different parts. The main counting part and the delay part. We have to define a
delay subroutine to generate delay between each number while counting. We are
considering that we have some external display which is connected through an
IO port, that will display the result in hexadecimal form.

Flow Diagram-:
Program Algorithm
MVI B,0FFH : Store FF into B
NEXT: INR B : Increment B
MVI C,0FFH : Store FF into C
DELAY: DCR C : Decrease C by 1
JNZ DELAY : Delay for FF time
MOV A,B : Load A with B
OUT 0010H : Send output to port 10
JMP NEXT : Jump to NEXT
HLT : Terminate program execution

Result-:

Counts are displaying into the output port 10.

You might also like