Micro Report Final
Micro Report Final
Statement: Add numbers 05H & 13H and display result in output port 03H.
1
2. Program to add two 8-bit numbers.
Statement: Add numbers from memory location 2050H & 2051H and store
result in memory location 2055H.
2
3
3. Program to subtract two 8-bit numbers.
Statement: Subtract numbers 25H & 12H and display result in output port 01H.
4
4. Program to subtract two 8-bit numbers.
Statement: Subtract numbers from memory location 2050H & 2051H and
store result in memory location 2055H.
Input: Output:
Memory Location Data Memory Location Data
2050H 65H 2055H 12H
2051H 53H
5
6
5. Program to find 1's complement of a number.
Statement: Input number from memory location 2013H and store result in
7
6. Program to find 2's complement of a number.
Statement: Input number from memory location 2013H and store result in
memory location 2052H.
8
7. Program to right shift 8-bit numbers.
Statement: Shift an eight-bit data four bits right. Assume data is in memory
location 2051H. Store result in memory location 2055H.
9
8. Program to left shift 8-bit numbers.
Statement: Shift an eight-bit data four bits right. Assume data is in memory
location 2051H. Store result in memory location 2055H.
10
9. Program to add two 16-bit numbers.
Statement: Add numbers 1124H & 2253H and store result in memory
location 2055H & 2056H.
Input: Output:
Register Pair Data Memory Location Data
HL 1124H 2055H 77H
DE 2253H 2056H 33H
11
12
10. Program to add two 16-bit numbers.
Statement: Input first number from memory location 2050H & 2051H and
second number from memory location 2052H & 2053H and store result in
memory location 2055H & 2056H.
LHLD 2052H // Load 16-bit number from memory location 2052H & 2053H
to HL pair
XCHG // Exchange contents of HL pair and DE pair
LHLD 2050H // Load 16-bit number from memory location 2050H & 2051H
to HL pair
MOV A, L // Move contents of register L to Accumulator
ADD E // Add contents of accumulator and E register
MOV L, A // Move contents of accumulator to Register L
MOV A, H // Move contents of register H to Accumulator
ADC D // Add contents of Accumulator and D register with carry
MOV H, A // Move contents of accumulator to Register L
SHLD 2055H //Store contents of HL pair in memory address 2055H & 2056H
HLT // Terminate the program.
Input: Output:
Memory Location Data Memory Location Data
2050H 33H 2055H 57H
2051H 45H 2056H 79H
2052H 24H
2053H 34H
13
14
11. Program to subtract two 16-bit numbers.
Statement: Subtract number 1234H from 4897H and store result in memory
location 2055H & 2056H.
Input: Output:
Register Pair Data Memory Location Data
HL 4897H 2055H 63H
DE 1234H 2056H 36H
15
16
12. Program to subtract two 16-bit numbers.
Statement: Input first number from memory location 2050H & 2051H and
second number from memory location 2052H & 2053H and store result in
memory location 2055H & 2056H.
LHLD 2052H // Load 16-bit number from memory location 2052H & 2053H
to HL pair
XCHG // Exchange contents of HL pair and DE pair
LHLD 2050H // Load 16-bit number from memory location 2050H & 2051H
to HL pair
MOV A, L // Move contents of register L to Accumulator
SUB E // Subtract contents of accumulator and E register
MOV L, A // Move contents of accumulator to Register L
MOV A, H // Move contents of register H to Accumulator
SBB D // Subtract contents of Accumulator and D register with carry
MOV H, A // Move contents of accumulator to Register L
SHLD 2055H // Store contents of HL pair in memory address 2055H & 2056H
HLT // Terminate the program.
Input: Output:
Memory Location Data Memory Location Data
2050H 78H 2055H 54H
2051H 45H 2056H 11H
2052H 24H
2053H 34H
17
18
13. Program to multiply two 8-bit numbers.
19
14. Program to divide two 8-bit numbers.
Statement: Divide 08H and 03H and store the quotient in memory location
2055H and the remainder in memory location 2056H.
20
21
15. Program to find the greatest among two 8-bit numbers.
Statement: Input numbers from memory location 2050H & 2051H and store the
greatest number in memory location 2055H.
LDA 2051H // Load content of memory location 2051H into Accumulator (A)
22
23
16. Program to find the smallest among two 8-bit numbers.
Statement: Input numbers from memory location 2050H & 2051H and store the
smallest number in memory location 2055H.
LDA 2051H // Load content of memory location 2051H into Accumulator (A)
MOV B, A // Move content of Accumulator (A) to Register B
LDA 2050H // Load content of memory location 2050H into Accumulator (A)
CMP B // Compare Accumulator (A) with Register B
JC X // Jump if Carry (A < B), meaning A is smaller
MOV A, B // Move content of Register B to Accumulator (A)
X: STA 2055H // Store the content of Accumulator (A) at memory location
2055H
HLT // Halt the program
Input: Output:
Memory Location Data Memory Location Data
2050H 05H 2055H 05H
2051H 07H
24
25
17. Program to find whether a number is odd or even..
Statement: Input number from memory location 2050H and store result in
2055H.
26
27
18. Program to find whether a number is odd or even..
Statement: Input number from memory location 2050H and store result in
2055H.
28
19. Display number from 1 to 10.
Output:
Memory Location Data
2050H 01H
2051H 02H
2052H 03H
2053H 04H
29
2054H 05H
2055H 06H
2056H 07H
2057H 08H
2058H 09H
2059H 10H
30
31
20. Find the sum of number from 1 to 10.
Output:
Memory Location Data
2055H 55H
32
33
21. Display all odd number from 1 to 10.
Output:
Memory Location Data
2050H 01H
2051H 03H
2052H 05H
2053H 07H
2054H 09H
34
35
22. Display all even number from 1 to 20.
Output:
Memory Location Data
2050H 02H
2051H 04H
2052H 06H
2053H 08H
2054H 10H
2055H 12H
2056H 14H
2057H 16H
2058H 18H
2059H 20H
36
37
23. Display all even number from 10 to 50.
Output:
Memory Location Data
2050H 10H 2060H 30H
2051H 12H 2061H 32H
2052H 14H 2062H 34H
2053H 16H 2063H 36H
2054H 18H 2064H 38H
2055H 20H 2064H 40H
2056H 22H 2066H 42H
2057H 24H 2067H 44H
2058H 26H 2068H 44H
2059H 28H 2069H 46H
2070H 48H
2072H 50H
38
39
24. Find sum of 10 numbers in array.
Input:
Memory Location Data
2050H 02H
2051H 04H
2052H 06H
2053H 01H
2054H 03H
2055H 07H
2056H 08H
2057H 09H
2058H 12H
2059H 04H
Output:
Memory Location Data
2060H 56H
40
41
25. Find the largest element in a block of data. The length of the block
is in the memory location 2200H and block itself starts from
memory location 2201H. Store the maximum number in memory
location 2300H.
LDA 2200H // Load the content of memory location 2200H into Accumulator
Input: Output:
Memory Location Data Memory Location Data
2200H 05H 2300H 58H
2201H 11H
2202H 25H
2203H 58H
2204H 08H
2205H 46H
42
43
26. Find the smallest number in array.
LDA 2200H // Load the content of memory location 2200H into Accumulator
MOV C, A // Move the content of Accumulator into register C
LXI H, 2201H // Load 2201H into H-L pair
MVI A, 00H // Move immediate value 00H into Accumulator
X: CMP M // Compare the content of Accumulator with memory location
JC Y // Jump to label Y if Carry flag is set (A < B)
MOV A, M // Move the content of memory location H-L pair into
Accumulator
Y: INX H // Increment H-L pair by 1
DCR C // Decrement register C by 1
JNZ X // Jump to label X if Zero flag is not set
STA 2300H // Store the content of Accumulator into memory location 2300H
HLT // Halt the program execution.
Input: Output:
Memory Location Data Memory Location Data
2200H 05H 2300H 00H
2201H 32H
2202H 12H
2203H 14H
2204H 34H
2205H 25H
44
45
27. Generate Fibonacci series up to 10th term.
Output:
Memory Location Data
2050H 00H 2057H 13H
2051H 01H 2058H 41H
2052H 01H 2059H 34H
2053H 02H
2054H 03H
2055H 05H
2056H 08H
46
47
28. Sort 10 numbers in ascending order in array.
48
49
29. Sort numbers in descending order in array. Length of array is in
memory location.
LDA 2050H // Load the content of memory location 2050H into Accumulator
MOV C, A // Move the content of Accumulator into register C
DCR C // Decrement register C by 1
X: MOV D, C // Move the content of register C to register D
LXI H, 2051H // Load 2051H into H-L pair
Y: MOV A, M // Move the content of memory location pointed by H-L pair to
Accumulator
INX H // Increment H-L pair by 1
CMP M // Compare the H-L pair with Accumulator
JNC Z // Jump to label Z if Carry flag is not set
MOV B, M // Move the content of memory location H-L pair to register B
MOV M, A // Move the content of Accumulator to memory location H-L pair
DCX H // Decrement H-L pair by 1
MOV M, B // Move the content of register B to memory location H-L pair
INX H // Increment H-L pair by 1
Z: DCR D // Decrement register D by 1
JNZ Y // Jump to label Y if Zero flag is not set
DCR C // Decrement register C by 1
JNZ X // Jump to label X if Zero flag is not set
HLT // Halt the program execution.
50
Input: Output:
Memory Location Data Memory Location Data
2050H 05H 2055H 57H
2051H 02H 2056H 06H
2052H 03H 2053H 04H
2053H 01H 2053H 03H
2053H 04H 2053H 02H
2053H 06H 2053H 01H
51
30. Multiply two 8-bit numbers 43H & 07H. Result is stored at address
3050 and 3051.
52
53
31. Multiply two 8-bit numbers stored at address 2050 and 2051.
Result is stored at address 3050 and 3051.
LDA 2050H // Load the content of memory location 2050H into Accumulator
MOV E, A // Move the content of Accumulator to register E
LDA 2051H // Load the content of memory location 2051H into Accumulator
MOV C, A // Move the content of Accumulator to register C
MVI D, 00H // Move immediate value 00H into register D
LXI H, 0000H // Load 0000H into H-L pair
X: DAD D // Add the content of H-L pair to D-E pair
DCR C // Decrement register C by 1
JNZ X // Jump to label X if Zero flag is not set
SHLD 3050H // Store the content of H-L pair into memory locations 3050H
and 3051H
HLT // Halt the program execution.
Input: Output:
Memory Location Data Memory Location Data
2050H 65H 2055H 12H
2051H 53H
54
55
Summary
56