0% found this document useful (0 votes)
27 views46 pages

8085 Notes

The document contains 7 sections that provide examples of assembly language programs (ALPs) to demonstrate various instructions of an 8-bit microprocessor. The sections cover data transfer instructions like MOV, MVI; arithmetic instructions like ADD, ADI; logic instructions; IO instructions; and register operations. Each ALP is provided along with its output showing the hex code, memory contents, register contents and flag settings after execution.

Uploaded by

Harka Pun
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)
27 views46 pages

8085 Notes

The document contains 7 sections that provide examples of assembly language programs (ALPs) to demonstrate various instructions of an 8-bit microprocessor. The sections cover data transfer instructions like MOV, MVI; arithmetic instructions like ADD, ADI; logic instructions; IO instructions; and register operations. Each ALP is provided along with its output showing the hex code, memory contents, register contents and flag settings after execution.

Uploaded by

Harka Pun
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
You are on page 1/ 46

Saurab Tharu(191809)

DATA TRANSFER INSTRUCTIONS

1. Write a simple program to enlighten MOV and MVI instructions.

Answer:
MVI C, 20H ;loads 20H into register C i.e. C <- 20H
MOV B, C ;copies content of register C to register B
; B <- C (20H)
MVI H, 50H ;loads 50H into register H i.e. H <- 50H
MVI L, 00H ;loads 00H into register L i.e. L <- 00H
MOV M, B ;copies content of register B to memory
; i.e. location pointed by [HL] pair
; i.e. [HL] = [5000H] <- B (20H)
HLT ; program stopped

1
Saurab Tharu(191809)

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

2
Saurab Tharu(191809)

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

3
Saurab Tharu(191809)

2. Write an assembly level program to swap contents stored in location


4560H and 5600H using MVI and MOV instructions.

Answer:
MVI H, 45H ; H = 45H
MVI L, 60H ; L = 60H
MVI A, 54H ; A = 54H
MOV M, A ; M = [4560H] = A = 54H i.e. M = [4560H] = 54H
MOV C, M ; C = M = 54H i.e. C = 54H
MVI H, 56H ; H = 56H
MVI L, 00H ; L = 00H
MVI B, 73H ; B = 73H
MOV M, B ; M = [5600H] = B = 73H i.e. M = [5600H] = 73H
MOV D, M ; D = M = 73H i.e. D = 73H
MOV M, C ; M = [5600H] = C = 54H i.e. M = [5600H] = 54H
MVI H, 45H ; H = 45H
MVI L, 60H ; L = 60H
MOV M, D ; M = [4560H] = D = 73H
HLT ; program stopped

4
Saurab Tharu(191809)

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

5
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

6
Saurab Tharu(191809)

3. Write an ALP to illustrate LXI, LDA and STA instructions.

Answer:

LXI H, 7090H ; [H] = 70H and [L] = 90H i.e. [HL] = 7090H
MVI M, 35H ; M = [HL] = 7090H <- 35H
LDA 7090H ; A <- [7090H] i.e. A = 35H
MVI A, 45H ; A = 45H
STA 7100H ; [7100H] <- [A] i.e. 7100H = 45H
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

7
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

8
Saurab Tharu(191809)

4. Write an ALP to enlighten LDAX and STAX instructions.

Answer:
suppose [7080H] = 56H

LXI B,7080H ; [B] = 70H and [C] = 80H i.e. [BC] = 7080H
LDAX B ; A =[BC] = [7080H] = 56H i.e. A = 56H
LXI D,7090H ; [D] = 70H and [E] = 90H i.e. [DE] = 7090H
MVI A, 34H ; A = 34H
STAX D ; [D] = [7090H] = A = 34H
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

9
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

10
Saurab Tharu(191809)

5. Write an ALP to illustrate LHLD and SHLD instructions.

Answer:
LXI H,4590H ; H = 45H and L = 90H i.e. [HL] = 4590H
MVI M,22H ; M = 22H i.e [HL] = [4590H] = 22H
MVI L,91H ; L = 91H
MVI M,4AH ; M = 4AH i.e. [HL] = [4591H] = 4AH
LHLD 4590H ; L = [4590H] = 22H
; H = [4591H] = 4AH
LXI H,AB34H ; H = ABH and L = 34H i.e. [HL] = AB34H
SHLD 7890H ; [7890H] = L = 34H
; [7891H] = H = ABH
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

11
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

12
Saurab Tharu(191809)

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

13
Saurab Tharu(191809)

6. Write an ALP to exchange the contents of BC Register pair (5678H)


and DE Register pair (89AB) using XCHG instructions.

Answer:
LXI B,5678H ; B = 56H and C = 78H i.e. [BC] = 5678H
MOV H,B ; H = B = 56H
MOV L,C ; L = C = 78H
LXI D,89ABH ; D = 89H and E = ABH i.e. [DE] = 89ABH
XCHG ; H = 89H and L = ABH
; D = 56H and E = 78H
MOV B,H ; B = 89H
MOV C,L ; C = ABH
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

14
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

15
Saurab Tharu(191809)

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

16
Saurab Tharu(191809)

7. Write a simple ALP to enlighten IO instructions associated with 8


bit microprocessor.

Answer:
IN 40H ; Read data from input port 40H and store in accumulator(A)
; A = Content received by 40H
MOV B,A ; B = [A] i.e. B = content of A
MVI A,ABH ; A = ABH
OUT 34H ; copies the content of accumulator to the output port 34H
; [34H] = content of A = ABH
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

17
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

18
Saurab Tharu(191809)

The content in the input and output port is given below:

19
Saurab Tharu(191809)

ARITHMETIC INSTRUCTIONS

1. Write an ALP to execute ADD and ADI instructions.

Answer:
MVI A,34H ; A = 34H
MVI C,45H ; C = 45H
ADD C ; A = A + C = 34H + 45H
ADI 9BH ; A = A + 9BH
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

20
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

21
Saurab Tharu(191809)

2. Write an ALP to execute SUB and SUI instructions.

Answer:
MVI A,34H ; A = 34H
MVI C,45H ; C = 45H
SUB C ; A = A - C = 34H - 45H
SUI 9BH ; A = A - 9BH
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

22
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

23
Saurab Tharu(191809)

3. Illustrate INR, INX, DCR and DCX instructions using a simple ALP.

Answer:
MVI C,6AH ; C = 6AH
INR C ; C = C + 1
LXI B,A35BH ; [BC] = A35BH
INX B ; [BC] = [BC] + 1
DCR B ; B = B - 1
DCX B ; [BC] = [BC] - 1
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

24
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program,


specified data after execution is given below:

25
Saurab Tharu(191809)

4. Write an ALP to add 16 bit numbers using ADD and ADC instructions.

Answer:
MVI A,45H ; A = 45H
MVI B,F8H ; B = F8H
ADD B ; A = A + B
MVI C,67H ; C = 67H
ADC C ; A = A + C + CY
ADI 78H ; A = A + 78H + CY
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

26
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

27
Saurab Tharu(191809)

5. Illustrate DAD instruction using a simple ALP.

Answer:

LXI H,56ABH ; H = 56H & L = ABH i.e. [HL] = 56ABH


LXI B,1A4BH ; B = 1AH & C = 4BH i.e. [BC] = 1A4BH
DAD B ; HL = HL + BC
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

28
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

29
Saurab Tharu(191809)

6. Write an ALP to enlighten DAA arithmetic instructions.

Answer:

MVI A, C4H ; A = C4H


MVI B, E9H ; B = E9H
ADD B ; A = A + B
DAA ; A = 13 & C = 1
HLT ; program stopped

The output of assembler with corresponding Hex-code, M-cycles and T-states is depicted
as shown in figure below:

30
Saurab Tharu(191809)

The contents of General purpose registers, accumulator, memory (M), flags and some
special registers after the execution of given program is shown below:

The contents of memory location including mnemonics of given program, specified data
after execution is given below:

31
Saurab Tharu(191809)

Timing diagram of MVI B,67H

32
Saurab Tharu(191809)

Timing diagram of MOV C,B

33
Saurab Tharu(191809)

Timing diagram of LXI D, 2374H

Timing diagram of LDA 7090H

34
Saurab Tharu(191809)

Timing diagram of STA 7100H

Timing diagram of LDAX B

35
Saurab Tharu(191809)

Timing diagram of STAX D

36
Saurab Tharu(191809)

Timing diagram of IN 40H

Timing diagram of OUT 34H

37
Saurab Tharu(191809)

Timing diagram of LHLD 4590H

38
Saurab Tharu(191809)

Timing diagram of SHLD 7890H

39
Saurab Tharu(191809)

Timing diagram of XCHG

40
Saurab Tharu(191809)

Timing diagram of ADD B

41
Saurab Tharu(191809)

Timing diagram of SUB C

42
Saurab Tharu(191809)

Timing diagram of INR C

43
Saurab Tharu(191809)

Timing diagram of DCR B

44
Saurab Tharu(191809)

Timing diagram of DAD B

45
Saurab Tharu(191809)

Timing diagram of DAA

46

You might also like