0% found this document useful (0 votes)
67 views

Muprgs

1. The document contains several microprocessor programs that perform arithmetic operations like addition, subtraction, multiplication, and division on numbers. It also contains programs for sorting arrays in ascending and descending order, transferring data between arrays, and converting between number systems. 2. The first program adds two 4-bit numbers stored in memory locations 2100 and 2101. The second program multiplies two 8-bit numbers stored in memory locations 1100 and 1101. The third program finds the largest number in an array stored starting at memory location 4150. 3. Other programs demonstrated include sorting arrays in ascending and descending order, converting between binary, decimal and hexadecimal number systems, and performing arithmetic operations like addition, subtraction and division on numbers stored in

Uploaded by

api-3724082
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Muprgs

1. The document contains several microprocessor programs that perform arithmetic operations like addition, subtraction, multiplication, and division on numbers. It also contains programs for sorting arrays in ascending and descending order, transferring data between arrays, and converting between number systems. 2. The first program adds two 4-bit numbers stored in memory locations 2100 and 2101. The second program multiplies two 8-bit numbers stored in memory locations 1100 and 1101. The third program finds the largest number in an array stored starting at memory location 4150. 3. Other programs demonstrated include sorting arrays in ascending and descending order, converting between binary, decimal and hexadecimal number systems, and performing arithmetic operations like addition, subtraction and division on numbers stored in

Uploaded by

api-3724082
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

1) Add Positive Nos.

LXI H, 2100
MVI B, 0
MVI D, FF
MVI C, 5
START: MOV A, M
RLC JC
NEXT
RRC
ADD B
CMP D
JC END
MOV B, A
NEXT: INX H
DCR C
JNZ START
END: STA 2000
HLT

2) Bubble Sort

MVI B, 05
START: LXI H, 2100
MVI C, 04
BACK: MOV A, M
INX H
CMP M
JC END
STA 2200
MOV A, M
DCX H
MOV M, A
LDA 2200
INX H
MOV M, A
END: DCR C
JNZ BACK
DCR B
JNZ START
HLT

3) Exchanging the Array Elements (Swap 2 Arrays)

LXI H, 2100
LXI D, 2200
MVI C, 0A
START: MOV A, M
STA 2300
LDAX D
MOV M, A
LDA 2300
STAX D
INX H
INX D
DCR C
JNZ START
HLT

4) Find the Highest No in an Array

LXI H, 2100
MVI C, 03
MOV A, M
DCR C
INX H
START: CMP M
JNC NEXT
MOV A, M
NEXT: INX H
DCR C
JNZ START
STA 2200
HLT

Microprocessor Programs

Multiplication of Two 4 bit Numbers

XRA A
LXI H, 2100
MOV B,M
INX H
L1: ADD M
DCR B
JNZ L1
STA 2102
HLT

Multiplication of Two 8-bit Numbers


XRA A
MOV B,A
LXI H, 1100
MOV C,M
INX H
L2: ADD M
JNC L1
INR B
L1: DCR C
JNZ L2
INX H
MOV M,A
INX H
MOV A,B
MOV M,A
HLT

Addition Of Two Numbers:

LDA 4150
MOV B,A
LDA 4151
ADD M
STA 4152
HLT

Addition Of Two no(method 2)

LXI H,2050
MOV A,M
INX H
ADD M
INX H
MOV A,B
HLT

Subtraction of Two no

LDA 4150
MOV B,A
LDA 4151
SUB B
STA 4152
HLT
Method 2 : Subtraction of Two No

LXI H,2050
MOV A,M
INX H
SUB M
INX H
MOV M,A
HLT

Biggest of Numbers

LXI H,4150
MOV C,M
INX H
MOV A,M
LOP: INX H
CMP M
JNC LOP1
MOV A,M
LOP1 DCR C
JNZ LOP
MOV M,A
HLT

Smallest of the No:

LXI H,4150
MOV C,M
LOOP: INX H
MOV A,M
INX H
CMP M
JC LOOP1
MOV A,M
LOOP1:DCR C
JNZ LOOP
MOV M,A
HLT

Division

XRA A
MOV C,A
LXI H,4150
MOV B,M
INX H
MOV A,M
P1: SUB B
JC L1
INC C
JMP P1
L1: ADD B
STA 4153
MOV AMC
STA 4152
HLT

Block Transfer

LXI H,2100
LXI D,2200
MVI C,0A
L1: MVI A,M
STAX D
INX H
INX D
DCR C
JNZ L1
HLT
RST 7

Ascending Order

LXI H,4150
MOV C,M
L1: MOV B,C
INX H
MOV A,M
PUSH H
DCR B
JZ LA1
L2: INX H
CMP M
JC L3
MOV D,A
MOV A,M
MOV M,D
L3: DCR B
JNZ L2
POP H
MOV M,A
DCR C
JMP L1
LA1: HLT

Decending Order:

LXI H,4150
MOV C,M
L1: MOV B,C
INX H
MOV A,M
PUSH H
DCR B
JZ LA1
L2: INX H
CMP M
JNC L3
MOV D,A
MOV A,M
MOV M,D
L3: DCR B
JNZ L2
POP H
MOV M,A
DCR C
JMP L1
HLT

Binary To BCD

LXI H,2101
MVI C,04
AGAIN: ORA M
DCR C
JZ FINISH
RLC
FINISH: INX H
JMP AGAIN
INX H
CPI OA
JC RESULT
MVI A,EE
RESULT: MOV M,A
MOV M,C
HLT

BCD To Binary

MVI D,08
LXI H,2100
MVI C,04
MOV B,M
AGAIN: MOV A,B
INX H
ANA D
JZ LOOP
MVI A,01
LOOP: MOV M,A
MOV A,D
RRC
MOV D,A
DCR C
JNZ AGAIN
HLT
Decimal to Hexa

XRA A
MOV C,A
LXI H,2100
MOV B,M
L1: ADI 64
JNC L2
INR C
DCR B
L2: JNZ L1
MOV D,A
INX H
MOV B,M
XRA A
ADI 0A
L3: DCR B
JNZ L3
INX H
ADD M
ADD D
JNC L4
INR C
L4: INX H
MOV M,C
INX H
MOV M,A
HLT

Hexa Decimal to Decimal

LXI H,4150
LXI B,0000
MOV A,M
SUI 64
JC L2
INR B
JMP L1
ADI 64
SUI OA
JC L4
INR C
MOV M,B
MOV B,A
MOV A,C
RLC
RLC
RLC
RLC
ADD B
INX H
MOV M,A
HLT
Sample Programs

1) TO ADD TWO 8-BIT DATA

LDA 000
MOV B,A
LDA 001
MVI C,00
ADD B
JNC AHEAD
INR C
[lab1] STA 002
MOV A,C
STA 003
HLT

Here, 000 -> 1st Operand 001 -> 2nd Operand


003 -> Sum 004 -> Carry
----------------------------------------------------------------

2) TO ADD TWO 8-BIT DATA PRESENT IN THE MEMORY

LXI H,000
MVI C,OO
MOV A,M
INX H
ADD M
JNC LAB1
INR C
[LAB1] INX H
MOV M,A
INX H
MOV M,C
HLT

Here, 000 -> 1st Operand 001 -> 2nd Operand


003 -> Sum 004 -> Carry
----------------------------------------------------------------

3) TO ADD TWO 16-BIT DATA

LHLD 000
XCHG
LHLD 002
XRA A
DAD D
JNC LAB1
INR A
[LAB1] SHLD 004
STA 006
HLT

Here, 000 & 001 -> 1st Operand 002 & 003 -> 2nd Operand
004 & 005 -> Sum 006 -> Carry
-----------------------------------------------------------------

You might also like