0% found this document useful (0 votes)
11 views57 pages

Micro Report Final

Uploaded by

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

Micro Report Final

Uploaded by

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

1. Program to add two 8-bit numbers.

Statement: Add numbers 05H & 13H and display result in output port 03H.

MVI A, 05H // Move data 05H to accumulator


MVI B, 13H // Move data 13H to B register
ADD B // Add contents of accumulator and B register
OUT 03H // Transfer result to output port 03H
HLT // Terminate the program.
Input: A=05H B=13H Output: (port 03H) = 18H

1
2. Program to add two 8-bit numbers.

Statement: Add numbers from memory location 2050H & 2051H and store
result in memory location 2055H.

LDA 2051H // Load contents of memory location 2051 to accumulator


MOV B, A // Move contents of accumulator to B register
LDA 2050H // Load contents of memory location 2050 to accumulator
ADD B // Add contents of accumulator and B register
STA 2055H // Store contents of accumulator in memory location 2055H
HLT // Terminate the program.
Input: Output:
Memory Location Data Memory Location Data
2050H 45H 2055H 98H
2051H 53H

2
3
3. Program to subtract two 8-bit numbers.

Statement: Subtract numbers 25H & 12H and display result in output port 01H.

MVI A, 25H // Move data 25H to accumulator


MVI B, 12H // Move data 12H to B register
SUB B // Subtract contents of accumulator and B register
OUT 01H // Transfer result to output port 01H
HLT // Terminate the program.
Input: A=25H B=12H Output: (port 03H) = 13H

4
4. Program to subtract two 8-bit numbers.

Statement: Subtract numbers from memory location 2050H & 2051H and
store result in memory location 2055H.

LDA 2051H // Load contents of memory location 2051 to accumulator


MOV B, A // Move contents of accumulator to B register
LDA 2050H // Load contents of memory location 2050 to accumulator
SUB B // Subtract contents of accumulator and B register
STA 2055H // Store contents of accumulator in memory location 2055H
HLT // Terminate the program.

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

memory location 2052H.

LDA 2013H // Load contents of memory location 2051 to accumulator


CMA // Complement contents of accumulator
STA 2052H // Store contents of accumulator in memory location 2052H
HLT // Terminate the program.
Input: Output:
Memory Location Data Memory Location Data
2013H 12H 2052H F3

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.

LDA 2013H // Load contents of memory location 2051 to accumulator


CMA // Complement contents of accumulator
ADI 01H //Add 01H to the contents of accumulator
STA 2052H // Store contents of accumulator in memory location 2052H
HLT // Terminate the program.
Input: Output:
Memory Location Data Memory Location Data
2013H 12H 2052H F4

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.

LDA 2051H // Load contents of memory location 2051 to accumulator


RAR // Rotate accumulator 1-bit right
RAR
RAR
RAR
STA 2055H // Store contents of accumulator in memory location 2055H
HLT // Terminate the program
Input: Output:
Memory Location Data Memory Location Data
2051H 12H 2055H 144

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.

LDA 2051H // Load contents of memory location 2051 to accumulator


RAL // Rotate accumulator 1-bit left
RAL
RAL
RAL
STA 2055H // Store contents of accumulator in memory location 2055H
HLT // Terminate the program
Input: Output:
Memory Location Data Memory Location Data
2051H 12H 2055H 192

10
9. Program to add two 16-bit numbers.

Statement: Add numbers 1124H & 2253H and store result in memory
location 2055H & 2056H.

LXI H, 1124H // Load 16-bit data 1124H to HL pair


LXI D, 2253H // Load 16-bit data 2253H to DE pair
MOV A, L // Move contents of register B 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 H
SHLD 2055H //Store contents of HL pair in memory address 2055H & 2056H
HLT // Terminate the program.

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.

LXI H, 4897H // Load 16-bit data 4897H to HL pair


LXI D, 1234H // Load 16-bit data 1234H to DE pair
MOV A, L // Move contents of register B 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 borrow
MOV H, A // Move contents of accumulator to Register H
SHLD 2055H //Store contents of HL pair in memory address 2055H & 2056H
HLT // Terminate the program.

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.

Statement: Multiply 06 and 03 and store the result in memory location


2055H.

MVI A, 00H // Initialize Accumulator (A) with 00H


MVI B, 06H // Move 06H to Register B
MVI C, 03H // Move 03H to Register C (used as a counter for multiplication)
X: ADD B // Add the content of Register B (06H) to Accumulator (A)
DCR C // Decrement Register C
JNZ X // Jump to label X if Register C is not zero
STA 2055H // Store the content of Accumulator (A) at memory location 2055H
HLT // Halt the program

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.

MVI A, 08H // Move Data (08H) to Accumulator (A)


MVI B, 03H // Move Data (03H) to Register B
MVI C, 00H // Move Data (00H) to Register C
X: CMP B // Compare Accumulator (A) with Register B
JC Y // Jump if Carry (A < B) to SUB B
SUB B // Subtract the content of Register B to Accumulator (A)
INR C // Increment Register C
JMP X // Jump unconditionally to label X
Y: STA 2056H // Store the content of Accumulator (A) at memory location 2056H
MOV A, C // Move the content of Register C (Quotient) to Accumulator (A)
STA 2055H // Store the content of Accumulator (A) at memory location 2055H
HLT //Halt the program
Output:
Memory Location Data
2055H 02H
2056H 02H

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)

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
JNC X // Jump if No Carry (A >= B), meaning A is greater or equal
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 08H 2055H 08H
2051H 04H

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.

LDA 2050H // Load the content of memory location 2050H into


Accumulator
ANI 01H // Perform a bitwise AND operation between Accumulator
and 01H.
JZ X // Jump to label Z if the result of the ANI operation is zero
MVI A, 0DH // Move immediate value 0DH into Accumulator
JMP Y // Unconditionally jump to label Y.
X: MVI A, 0EH // Move immediate value 0EH into Accumulator.
Y: STA 2055H // Store the content of Accumulator into memory location
2055H.
HLT // Halt the program execution.
.Input: Output:
Memory Location Data Memory Location Data
2050H 03H 2055H 13H

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.

LDA 2050H // Load data from 2050H into Accumulator


MVI C, 08H // Move immediate value 08H into register C
MVI B, 00H // Move immediate value 00H into register B
X: RAR // Rotate Accumulator Right
JNC Y // Jump to label Y if Carry flag is not set
INR B // Increment register B by 1
Y: DCR C // Decrement register C by 1
JNZ X // Jump to label X if Zero flag is not set
MOV A, B // Move the content of register B to Accumulator
STA 2055H // Store the content of Accumulator into memory location 2055H
HLT // Halt the program execution.
Input: Output:
Memory Location Data Memory Location Data
2050H 76H 2055H 03H

28
19. Display number from 1 to 10.

LXI H, 2050H // Load 2050H into H-L pair


MVI B, 01H // Move immediate value 0AH into register B
MVI C, 0AH // Move immediate value 01H into register C
X: MOV M, B // Move the content of register B to memory location H-L pair
INX H // Increment register pair HL
INR B // Increment register B by 1
DCR C // Decrement register B by 1
JNZ X // Jump to label X if Zero flag is not set
HLT // Halt the program execution.

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.

LXI H, 2050H // Load 2050H into H-L pair


MVI B, 01H // Move immediate value 01H into register B
MVI C, 0AH // Move immediate value 0AH into register C
MVI A, 00H // Move immediate value 00H into Accumulator
X: ADD B // Add the content of register C to Accumulator
INX H // Move the content of Accumulator to register C
INR B // Increment register D by 1
DCR C // Decrement register B by 1
JNZ X // Jump to label X if Zero flag is not set
STA 2055H // Store the content of Accumulator into memory location 2055H
HLT // Halt the program execution.

Output:
Memory Location Data
2055H 55H

32
33
21. Display all odd number from 1 to 10.

LXI H, 2050H // Load 2050H into H-L pair


MVI B, 01H // Move immediate value 01H into register B
MVI C, 0AH // Move immediate value 0AH into register C
X: MOV M, B // Move the content of register B to memory location H-L pair
INX H // Increment register pair HL by 1
INR B // Increment register B by 1
INR B // Increment register B by 1
DCR C // Decrement register C by 1
DCR C // Decrement register C by 1
JNZ X // Jump to label X if Zero flag is not set
HLT // Halt the program execution.

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.

LXI H, 2050H // Load 2050H into H-L pair


MVI B, 02H // Move immediate value 02H into register B
MVI C, 14H // Move immediate value 14H into register C
X: MOV M, B // Move the content of register B to memory location H-L pair
INX H // Increment HL register pair by 1
INR B // Increment register B by 1
INR B // Increment register B by 1
DCR C // Decrement register C by 1
DCR C // Decrement register C by 1
JNZ X // Jump to label X if Zero flag is not set
HLT // Halt the program execution.

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.

LXI H, 2050H // Load 2050H into H-L pair


MVI B, 0AH // Move immediate value 0AH into register B
MVI C, 32H // Move immediate value 32H into register C
X: MOV M, B // Move the content of register B to memory location H-L pair
INX H // Increment HL register pair by 1
INR B // Increment register B by 1
INR B // Increment register B by 1
DCR C // Decrement register C by 1
DCR C // Decrement register C by 1
JNZ X // Jump to label X if Zero flag is not set
HLT // Halt the program execution.

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.

LXI H, 2050H // Load 2050H into H-L pair


MVI C, 0AH // Move immediate value 0AH into register C
MVI A, 00H // Move immediate value 00H into Accumulator
X: MOV B, M // Move the content of memory location H-L pair into register B
ADD B // Add the content of register B to Accumulator
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 2060H // Store the content of Accumulator into memory location 2060H
HLT // Halt the program execution.

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

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 register B
X: CMP M // Compare the content of memory location H-L pair with
Accumulator
JNC Y // Jump to label Y if Carry flag is not set
MOV A, M // Move the content of memory location H-L pair to Accumulator
Y: INX H // Increment H-L pair by 1 (point to next memory location)
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 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.

LXI H, 2050H // Load 2050H into H-L pair


MVI C, 08H // Move immediate value 08H into register C
MVI B, 00H // Move immediate value 00H into register B
MVI D, 01H // Move immediate value 01H into register D
MOV M, B // Move the content of register B to memory location H-L pair
INX H // Increment H-L pair by 1
MOV M, D // Move the content of register D to Memory location HL pair
X: MOV A, B // Move the content of register B to Accumulator
ADD D // Add the content of register D to Accumulator
MOV B, D // Move the content of register D to register B
MOV D, A // Move the content of Accumulator to register D
INX H // Increment H-L pair by 1
MOV M, D // Move the content of register D to Memory location HL pair
DCR C // Decrement register C by 1
JNZ X // Jump to label X if Zero flag is not set
HLT // Halt the program execution.

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.

MVI C, 0AH // Move immediate value 0AH 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, 2050H // Load 2050H into H-L pair
Y: MOV A, M // Move the content of memory location H-L pair to Accumulator
INX H // Increment H-L pair by 1
CMP M // Compare the H-L pair with Accumulator
JC Z // Jump to label Z if Carry flag is 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.
Input: Output:
Memory Location Data Memory Location Data
2050H 05H 2055H 57H
2051H 03H 2056H 79H
2052H 05H 2053H 34H
2053H 02H 2053H 34H
2053H 06H 2053H 34H
2053H 08H 2053H 34H

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.

LXI H, 0000H // Load 0000H into H-L pair


MVI D, 00H // Move immediate value 00H into register D
MVI E, 43H // Move immediate value 43H into register E
MVI C, 07H // Move immediate value 07H into register C
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 2051H
HLT // Halt the program execution.
Output:
Memory Location Data
3050H 213H
3051H 01H

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

This lab focused on understanding and implementing basic 8085 microprocessor


programs using the GNUSim8085 simulator. The objective was to gain hands-on
experience in low-level programming, memory operations, and processor
instructions.

Key experiments included:

Arithmetic operations (addition, subtraction, multiplication).


Data transfer using LDA, STA, MOV, MVI, and LXI instructions.
Logical operations (CMA, CMP, RAR, RAL).
Looping and conditional branching using JMP, JNZ, and JC.
Programs to find the sum, largest element, and complement of data.
Understanding memory-mapped I/O through instruction flow.

The GNUSim8085 environment provided an easy interface to enter, assemble,


and run programs, and observe memory/register changes in real time. Each
experiment enhanced understanding of the 8085 instruction set, register usage,
flag behavior, and program control flow.

This lab laid a strong foundation for programming microprocessors and


analyzing their internal working mechanisms.

56

You might also like