0% found this document useful (0 votes)
3 views16 pages

MP Lab File Final

The document is a practical file for a microprocessor course at Maharshi Dayanand University, containing various assembly language programs for the 8085 and 8086 microprocessors. It includes programs for adding numbers, finding the largest number, sorting, and computing 2's complement, along with detailed memory addresses, mnemonics, and results. Each experiment is structured with data entered, memory addresses, and comments explaining the operations performed.

Uploaded by

arcade.kush
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views16 pages

MP Lab File Final

The document is a practical file for a microprocessor course at Maharshi Dayanand University, containing various assembly language programs for the 8085 and 8086 microprocessors. It includes programs for adding numbers, finding the largest number, sorting, and computing 2's complement, along with detailed memory addresses, mnemonics, and results. Each experiment is structured with data entered, memory addresses, and comments explaining the operations performed.

Uploaded by

arcade.kush
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIVERSITY INSTITUTE OF

ENGINEERING & TECHNOLOGY

MAHARSHI DAYANAND UNIVERSITY


ROHTAK

PRACTICAL FILE
MICROPROCESSOR (ESC-CSE-301G)

SUBMITTED TO : SUBMITTED BY :

DR. ANIL SANGWAN Kushagra


Varshney
UIET, MDU 2314067

5TH SEM ( CSE - A)


INDEX
S. Programs Page Remarks
NO. No.

1. To write an 8085 Assembly Language Program to add 1


two 8-bit numbers stored at memory locations
2050H and 2051H. The 8-bit sum is to be stored at
location 2052H and the carry (if any) at 2053H.

2. To write an 8085 Assembly Language Program to add 2


a 16-bit number stored at 2050H (low byte) and
2051H (high byte) with another 16-bit number at
2052H (low byte) and 2053H (high byte). The 16-bit
result is stored at 2054H−2055H and the final carry at
2056H.

3. To write an 8085 Assembly Language Program to add 3-4


a series of 10 eight-bit numbers stored in memory
from location 2050H to 2059H. The 16-bit result is
stored at 2060H (low byte) and 2061H (high byte).

4. To write an 8085 Assembly Language Program to 5


find the largest 8-bit number from a series of 10
numbers stored in memory from location 2050H to
2059H. The result (the maximum value) is stored at
memory location 2060H.

5. To write an 8085 Assembly Language Program to sort 6-8


5 numbers from 2050H−2054H and stores the sorted
list (descending) at 2060H−2064H using a main
routine and two subroutines.

6. To write a 8085 assembly language program for 9


finding 2’s complement of a 16 – bit number stored at
2500 – 2501 H. The result is stored at 2600 – 2601
H.

7. Write an 8086 assembly program to add two 32-bit 10


numbers stored in memory locations
2500H–2503H and 2504H–2507H, and store the
32-bit sum at memory location 2600H–2603H.

2314008
8. a ) Write an 8086 assembly program to move a block 11-12
of data from memory location 2500H–2507H to
2600H–2607H without using string manipulation
instructions like MOVSB or MOVSW. b) Write an
8086 assembly program to move a block of data from
memory location 2500H–2507H to 2600H–2607H
using string manipulation instructions

2314008
EXPERIMENT1
To write an 8085 Assembly Language Program to add two 8-bit numbers stored at memory
loca ons 2050H and 2051H. The 8-bit sum is to be stored at loca on 2052H and the carry (if
any) at 2053H.

Data Entered:
• First 8-bit number stored at memory loca on 2050H : 47H
• Second 8-bit number stored at memory loca on 2051H: 80H

Memory Lab Mnemonic Operand Opcode(s), Comment


Address(es) el s s (Hex)

Load first number into


2000-2002 LDA 2050 3A,50,20 A.

2003 - MOV B, A 47 Store it in B.

2004-2006 - LDA 2051 3A,51,20 Load second number into A

2007 - ADD B 80 Add B to A. Result in A.

2008-200A - STA 2052 32,52,20 Store sum at 2052H.

200B,200C - MVI A, 00H 3E,00 Clear A.

200D - ADC A 8F Move carry flag to A's LSB.

200E-2010 - STA 2053 32,53,20 Store carry status at 2053H.

2011 - HLT - 76 Halt.

Result:
• Sum of the two 8-bit numbers is stored at memory location 2052H : C7H
• Carry (if any) is stored at memory location 2053H : No carry in our example

2314008
EXPERIMENT 2
To write an 8085 Assembly Language Program to add a 16-bit number stored at 2050H (low
byte) and 2051H (high byte) with another 16-bit number at 2052H (low byte) and 2053H (high
byte). The 16-bit result is stored at 2054H−2055H and the final carry at 2056H.

Data Entered:
• First 16-bit number stored at memory loca ons 2050H−2051H: 1234H (Low byte = 34H, High
byte = 12H)
• Second 16-bit number stored at memory loca ons 2052H−2053H: 5678H (Low byte = 78H,
High byte = 56H)

Memory Label Mnemonic Operand Opcode(s) Comment


Address(es) (Hex)
Load first 16-bit
2000−2002 LHLD 2050H 2A, 50, 20 number into HL.

Move first number


2003 - XCHG - EB to DE pair.

Load second
16-bit number
2004−2006 - LHLD 2052H 2A, 52, 20
into HL.

2007 - DAD D 19 Add DE to HL.


Result in HL.

2008−200A - SHLD 2054H 22, 54, 20 Store 16-bit result


from HL.

200B−200C - MVI A, 00H 3E, 00 Clear A to prepare


for carry storage.

Move carry flag


200D - ADC A 8F (from DAD) to
A's LSB.

Store final carry


200E-2010 - STA 2056H 32, 56, 20 status.

2011 - HLT - 76 Halt.

Result:
• 16-bit sum of the two numbers (1234H + 5678H = 68ACH) is stored at memory loca ons
2054H−2055H
o 2054H (Low byte) = ACH
o 2055H (High byte) = 68H
• Final carry (if any) is stored at memory loca on 2056H = 00H

2314008
EXPERIMENT 3
To write an 8085 Assembly Language Program to add a series of 10 eight-bit numbers stored in
memory from loca on 2050H to 2059H. The 16-bit result is stored at 2060H (low byte) and
2061H (high byte).

Data Entered:
• A series of 10 eight-bit numbers are stored in memory loca ons 2050H to 2059H.
Example values used: 05H, 0AH, 03H, 07H, 0FH, 12H, 08H, 09H, 0CH, 06H.
Memory Label Mnemonic Operand Opcode(s) (Hex) Comment
Address(es)
Initialize HL
2000−2002 LXI H, 2050H 21, 50, 20 as memory
pointer.
2003−2004 - MVI C, 0AH 0E, 0A Initialize C as counter
with 10.

Use B as high byte of


2005−2006 - MVI B, 00H 06, 00 sum. Clear it.

2007 - XRA A AF Use A as low byte of


sum. Clear it.
Add number from
2008 LOOP ADD M 86 memory to
accumulator.

If no carry, skip
2009−200B - JNC SKIP D2, 0D, 20 incrementing high
byte.
If carry, increment
200C - INR B 4 high byte (Register
B).
Point to next memory
200D SKIP INX H 23 location.

200E - DCR C 0D Decrement counter.

If counter not zero,


200F−2011 - JNZ LOOP C2, 08, 20 repeat loop.

2012−2014 - STA 2060H 32, 60, 20 Store low byte of


sum (from A).

Move high byte of


2015 - MOV A, B 78 sum to A.

Store high byte of


2016−2018 - STA 2061H 32, 61, 20 sum.

2019 - HLT - 76 Halt.

Result:
2314008
• The 16-bit sum of the 10 numbers is stored at memory loca ons 2060H (low byte) and 2061H
(high byte). For the example data, the sum = 0064H, with 2060H = 5DH and 2061H = 00H.

2314008
EXPERIMENT 4
To write an 8085 Assembly Language Program to find the largest 8-bit number from a series of
10 numbers stored in memory from loca on 2050H to 2059H. The result (the maximum value)
is stored at memory loca on 2060H.

Data Entered:
• A series of 10 numbers are stored at memory loca ons 2050H–2059H.
Example values: 12H, 07H, 2AH, 1FH, 09H, 15H, 20H, 0CH, 18H, 14H.

Memory Label Mnemonic Operand Opcode(s) (Hex) Comment


Address(es)
Initialize HL
2000−2002 LXI H, 2050H 21, 50, 20 as memory
pointer.
2003 - MOV A, M 7E Assume first
number is the
max.
Set counter for the
2004−2005 - MVI C, 09H 0E, 09 remaining 9
numbers.
2006 LOOP INX H 23 Point to the next
number.
Compare current
2007 - CMP M BE max (in A) with
memory data.

If A >= M (No Carry),


2008−200A - JNC SKIP D2, 0C, 20 don't update the max.

If A < M (Carry),
200B - MOV A, M 7E update max with
new number.

200C SKIP DCR C 0D Decrement counter.

200D−200F - JNZ LOOP C2, 06, 20 If counter not zero,


repeat loop.

Store final
2010−2012 - STA 2060H 32, 60, 20 maximum value.

2013 - HLT - 76 Halt.

Result:
The largest number among the 10 values is stored at memory loca on 2060H.
For the example data, the maximum value = 2AH

2314008
EXPERIMENT 5
To write an 8085 Assembly Language Program to sort 5 numbers from 2500H−2505H and
stores the sorted list (descending) at 2600H−2604H using a main rou ne and two subrou nes.

Data Entered:
• Count is at memory loca on 2500
• Five numbers are stored at memory loca ons 2050H–2054H.
Example values: 15H, 0AH, 2CH, 18H, 05H.

MAIN PROGRAM

MEMORY LABEL MNEMONICS OPERANDS HEX CODE COMMENT


ADDRESS
2000 LXI D,2600 11,01,26 Memory
locations to
store the
results.
2003 LXI H,2500 21,00,25 Count
address in
HL pair.
2006 MOV B,M 46 Count in
register B to
check whether
all numbers
have been
arranged in
descending
order.
2007 START CALL 2200 CD,00,22 Call
subroutine 1
to find the
largest
number.
200A STAX D 12 Store result.
200B CALL 2500 CD,50,20 Call
subroutine 2
to check
which number
is largest.
200E INX D 13
200F DCR B 05 Have all
numbers been
arranged in
descending
order?
2010 JNZ START C2,07,20 No ,repeat
process.
2013 HLT 76 Stop

SUBROUTINE-1:
2314008
MEMORY LABEL MNEMONICS OPERANDS HEX CODE COMMENT
ADDRESS
2200 LXI H,2500H 21,00,25 Address for
count in H-L
pair.
2203 MOV C,M 4E Count in
register C.
2204 SUB A 97 Make content
of
accumulator
zero.
2205 LOOP INX H 23
2206 CMP M BE Compare next
number with
previous max.
Is next
number >
previous max?

2207 JNC AHEAD D2,0B,22 No larger


number is in
accumulator.
Go to label
ahead.
220A MOV A,M 7E Yes,get larger
number in
accumulator.
220B AHEAD DCR C 0D
220C JNZ LOOP C2,05,22
220F RET C9

SUBROUTINE-2:
2050 LXI H,2500H 21,00,25

2053 MOV C,M 4E Count to check which no.


was selected as largest one.
2054 BEHIND INX H 23 Get next no.
2055 CMP M BE Compare the next no. with
largest one which is in
accumulator.
2056 JZ FORWARD CA,5D,20 Is the present no. largest
one? Yes, go to forward
2059 DCR C 0D Decrement count.

2314008
205A JNZ BEHIND C2,54,20 No, jump to take up next no.

205D FORWARD MVI A,00 3E,00

205F MOV M,A 77 Replace largest no. by 00.

2060 RET C9

Result:

The sorted numbers in descending order are stored at memory loac ons 2600H to

2604H.

For the example data the sorted list= 2CH,18H,15H,0AH,05H

2314008
EXPERIMENT 6

To write a 8085 assembly language program for finding 2’s complement of a 16 – bit number stored at
2500 – 2501 H. The result is stored at 2600 – 2601 H.
Data Entered :
16-bit number stored at 2500H–2501H.
Example: 1234H → Low byte = 34H, High byte = 12H

Memory Operan
Label Mnemonic Opcode(s) (Hex) Comment
Address(es) d
Load HL with address of
2000–2002 - LXI H 2500H 21, 00, 25 16-bit number
Load low byte (L) into
2003 - MOV A, M - 7E
accumulator
2004 - CMA - 2F Complement low byte
Add 1 to get 2’s
2005 - INR A - 3C complement of low byte
Store low byte back to
2006 - MOV L, A - 77 memory
2007 - INX H - 23 Point HL to high byte (H)
Load high byte into
2008 - MOV A, M - 7E
accumulator
2009 - CMA - 2F Complement high byte
SKIP_CHEC If no carry from low byte,
200A JNC SKIP - D2, 0D, 20
K skip increment
Add 1 to high byte
200B - INR A - 3C
because carry exists
Store high byte back to
200C SKIP MOV M, A - 77
memory
LXI H, 21, 00, Load HL with address
200D–200F - 2600H 26 to store result
2010 - MOV A, L - 7F Load low byte of result
STA
2011 - - 32, 00, 26 Store low byte at 2600H
2600H
2012 - MOV A, H - 7C Load high byte of result
STA
2013 - - 32, 01, 26 Store high byte at 2601H
2601H
2014 - HLT - 76 Halt program

Result:
2’s complement stored at 2600H–2601H:
• Low byte (2600H) = CCH
• High byte (2601H) = EDH

2314008
EXPERIMENT 7

Write an 8086 assembly program to add two 32-bit numbers stored in memory loca ons 2500H–2503H and
2504H–2507H in segment 1000H and store the 32-bit sum at memory loca on 2600H–2603H

Data Entered
• First 32-bit number at 2500H–2503H: 12345678H
o 2500H = 78H (least significant byte)
o 2501H = 56H
o 2502H = 34H
o 2503H = 12H (most significant byte)
• Second 32-bit number at 2504H–2507H: 87654321H
o 2504H = 21H
o 2505H = 43H
o 2506H = 65H
o 2507H = 87H

Memory Table
Memory Lab Operan Opcode(s)
Mnemonic Comment
Address(es) el d (Hex)
Load low word (first 16 bits) of first
2000-2001 - MOV AX [2500H] 8B,06,00,25 number
2002-2003 - ADD AX [2504H] 03,06,04,25 Add low word of second number
MOV
2004 - AX 89,06,00,26 Store low word of sum
[2600H]
Load high word (most significant 16 bits)
2005-2006 - MOV AX [2502H] 8B,06,02,25 of first number
Add high word of second number + carry
2007-2008 - ADC AX [2506H] 13,06,06,25 from low word
MOV
2009 - AX 89,06,02,26 Store high word of sum
[2602H]
200A MOV AL 00H
200B ADC AL AL
MOV
200C AL
[2604H]
200D - HLT - F4 Halt program

Result :

• 32-bit sum stored at 2600H–2603H


• 2600H = 99H (least significant byte)
• 2601H = 99H
• 2602H = 99H
• 2603H = 99H (most significant byte)
• 2604H = 0 CARRY STATUS
• Explana on of Carry Handling:
ADD adds the low 16 bits.
ADC adds the high 16 bits along with the carry from low word addi on

2314008
EXPERIMENT 8

a ) Write an 8086 assembly program to move a block of data from memory loca on 2500H–2507H to
2600H–2607H without using string manipula on instruc ons like MOVSB or MOVSW.

Data Entered (Example)


• Source blo at 2500H–2507H (8 bytes): 11H, 22H, 33H, 44H, 55H, 66H, 77H, 88H
• Des na on blo at 2600H–2607H ini ally empty: 00H

Memory Table (8086 Program)


Memory Address(es) Label Mnemonic Operand
2000 - MOV CX 000AH
2002-2003 - MOV SI 0500H
2004 - MOV DI 0600H
2005 BACK MOV AX 1000H
2006 LOOP_START MOV DS AX
2007 - MOV AL [SI]
2008 - MOV BX 2000H
2009 - MOV DS BX
200A - MOV [DI] AL
200B - INC SI -
200C - INC DI -
200D - DEC CX -
200E — JNZ BACK -
200F — HLT -

Result :
Des na on memory blo 2600H–2607H a er execu on:
• 2600H = 11H
• 2601H = 22H
• 2602H = 33H
• 2603H = 44H
• 2604H = 55H
• 2605H = 66H
• 2606H = 77H
• 2607H = 88H

b) Write an 8086 assembly program to move a block of data from memory loca on 2500H–2507H to
2600H–2607H using string manipula on instruc ons (MOVSB).
2314008
Data Entered
• Source blo at 2500H–2507H (8 bytes): 11H, 22H, 33H, 44H, 55H, 66H, 77H, 88H
• Des na on blo at 2600H–2607H ini ally empty: 00H

Memory Table

Memory Address(es) Label Mnemonic Operand


2000 - MOV CX 000AH
2002-2003 - MOV AX 1000H
2004-2005 - MOV DS AX
2006 - MOV AX 2000H
2007 - MOV ES AX
2008 - MOV SI 0500H
2009 MOV DI 0600H
CLD -
REP MOV SB -
HLT

Result :
Des na on memory blo 2600H–2607H a er execu on:
• 2600H = 11H
• 2601H = 22H
• 2602H = 33H
• 2603H = 44H
• 2604H = 55H
• 2605H = 66H
• 2606H = 77H
• 2607H = 88H

2314008
2314008

You might also like