Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

DR. B.R.

AMBEDKAR NATIONAL INSTITUTE OF


TECHNOLOGY, JALANDHAR

MICROPROCESSOR AND INTERFACING LAB


LAB ASSIGNMENT 4

SUBMITTED TO:
DR. SATHIYA S

SUBMITTED BY:
 PARTH SHINH
18106052
 PIYUSH GUPTA
18106053
 PRABHLEEN KAUR
18106054
ICE 3RD Year

Group: G3-C
QUESTION 1:
 AIM:
Subtract two numbers, check for negative. If the result is negative store the number in
2000H. If it is positive, increment the result once and store it in 2005H.

 PLATFORM REQUIRED:
SIM8085

 ALGORITHM OF THE PROGRAM:


1. Store 2 numbers on which operations has to be performed in different memory
locations.
2. Load first number (location) into HL pair of register and move it to accumulator.
3. Then load second number (location) into HL pair of register and move it to other
pair of registers let’s say B register.
4. Subtract this two numbers.
5. If result is negative (i.e. if carry flag set), store result in 2000H location.
6. Else increment the result, then store it in 2005H location.
7. Terminate the program.

 PROGRAM SEQUENCE IN MNEMONICS:


LXI H,200AH
MOV A,M
LXI H,201AH
MOV B,M
SUB B
JC L1
INR A
STA 2005H
HLT
L1: STA 2000H
HLT

 FLOWCHART:
START

Load 1st no to AC , 2nd no to register B

Subtract these numbers

HLT

If result
Store result at
YES is –ve NO Increment
2000H
(JC set) the result
HLT

Store result at
2005H
 PROGRAM OUTPUT:
 RESULT:
Two hexadecimal numbers are subtracted. If result is negative which is check by carry
flag. Carry flag set means borrow is taken therefore, result will be negative. Negative
result simply stored at 2000H location else if result is positive means carry flag is not
set then result is incremented then store at location 2005H.

QUESTION 2:
 AIM:
write program to execute multiplication of two 8-bit numbers.

 PLATFORM REQUIRED:
SIM8085

 ALGORITHM OF THE PROGRAM:

1. Store 2 numbers in memory on which operation has to perform.


2. Firstly, store 00H in register B.
3. Load 1st number to register C and 2nd number to register D.
4. Store 00H in Accumulator to avoid error by any previous results.
5. Perform addition with number stored in D.
6. If addition generate carry, then increment register B.
7. Decrement register C.
8. These steps repeat again till register C get decremented to zero.
9. Then store result and carry at consecutive locations.
10. Terminate the program.

 PROGRAM SEQUENCE IN MNEMONICS:

MVI B,00H
LXI H,0044H
MOV C,M
LXI H,0055H
MOV D,M
MVI A,00H
L2: ADD D
JNC L1
INR B
L1: DCR C
JNZ L2
STA 0053H
MOV A,B
STA 0052H
HLT
 FLOWCHART:

START

Store 00H in register B and


AC

Load numbers to register C and


register D

ADD D

If result Increment
has YES register B
carry

Decrement register C

If
NO register Store the result
YES
C=0

HLT
 PROGRAM OUTPUT:
 RESULT:
Multiplication of two hexadecimal numbers was performed.

You might also like