Anda di halaman 1dari 17

MICROPROCESSOR LAB MANUAL

(8085-TRAINER KIT & 8086 MASM)

LAB EXPERIMENTS
PART A(8085)
1. FAMILIARISATION OF 8085 MICROPROCESSOR TRAINER KIT.
2. ADDITION OF TWO 8-BIT NUMBERS.
3. SUBTRACTION OF TWO 8 BIT NUMBERS.
4. MULTIPLICATION OF TWO 8-BIT NUMBERS
5. DIVISION OF TWO 8-BIT NUMBERS
6. LARGEST NUMBER IN AN ARRAY OF DATA.
7. SMALLEST NUMBER IN AN ARRAY OF DATA
8. BCD ADDITION
9. BCD SUBTRACTION
10.SUM OF N NUMBERS
11.ARRANGE AN ARRAY OF DATA IN ASCENDING ORDER
12.ARRANGE AN ARRAY OF DATA IN DESCENDING ORDER
13. HEX TO ASCII CONVERSION
14. ASCII TO HEX CONVERSION
15. SQUARE OF A NUMBER USING LOOK UP TABLE
16. BLOCK OF DATA TRANSFER
17. BLOCK INTERCHANGE
18. BLOCK INVERSION
16.STEPPER MOTOR INTERFACE
17. DISPLAY INTERFACE

PART B
1.FAMILIARISATION OF 8086-MASM

(a). Introduction to IBM/PC and its DEBUG program commands


- Examining and modifying the contents of the memory
- Assembling 8086 instructions with the ASSEMBLER commands
- Debugging a program
(b). Assembly language program development using IBM/PC Macro
assembler
- Creating an Assembler source file
- Assembling source program with MASM
- The link program - creating a RUN module
2. DISPLAY MESSAGE
3. ADDITION OF TWO 8-BIT NUMBERS.
4. CHECK EVEN OR ODD NUMBER.

PART A
1. ADDITION OF TWO 8 BIT NUMBERS
ALGORITHM:
1) Start the program by loading the first data into Accumulator.
2) Move the data to a register (B register).
3) Get the second data and load into Accumulator.
4) Add the two register contents.
5) Check for carry.
6) Store the value of sum and carry in memory location.
7) Terminate the program.
PROGRAM:
MVI
LDA
MOV
LDA
ADD
JNC
INR
LOOP: STA
MOV
STA
HLT

C, 00
8150
B, A
8151
B
LOOP
C
8152
A, C
8153

; Initialize C register to 00
; Load the value to Accumulator.
; Move the content of Accumulator to B register.
; Load the value to Accumulator.
; Add the value of register B to A
; Jump on no carry.
; Increment value of register C
; Store the value of Accumulator (SUM).
; Move content of register C to Acc.
; Store the value of Accumulator (CARRY)
; Halt the program.

OBSERVATION:
Input:

80 (8150)
80 (8251)

Output:

00 (8152)
01 (8153)

2. SUBTRACTION OF TWO 8 BIT NUMBERS


ALGORITHM:
1. Start the program by loading the first data into Accumulator.
2. Move the data to a register (B register).
3. Get the second data and load into Accumulator.
4. Subtract the two register contents.
5. Check for carry.
6. If carry is present take 2s complement of Accumulator.
7. Store the value of borrow in memory location.
8. Store the difference value (present in Accumulator) to a memory
location and terminate the program.
PROGRAM:
MVI
LDA
MOV
LDA
SUB
JNC
CMA
INR
INR
LOOP: STA
MOV
STA
HLT

C, 00
8150
B, A
8151
B
LOOP

Initialize C to 00
Load the value to Acc.
Move the content of Acc to B register.
Load the value to Acc.

Jump on no carry.
Complement Accumulator contents.
A
Increment value in Accumulator.
C
Increment value in register C
8152 Store the value of A-reg to memory address.
A, C
Move contents of register C to Accumulator.
8153 Store the value of Accumulator memory address.
Terminate the program.

OBSERVATION:
Input: 06 (8150)
02 (8251)
Output: 04 (8152)
01 (8153)

3. MULTIPLICATION OF TWO 8 BIT NUMBERS


ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register (B register).
3) Get the second data and load into Accumulator.
4) Add the two register contents.
5) Check for carry.
6) Increment the value of carry.
7) Check whether repeated addition is over and store the value of product and carry
in memory location.
8) Terminate the program.
PROGRAM:
MVI
MVI
LXI
MOV
INX
MOV
LOOP: ADD
JNC
INR
NEXT:DCR
JNZ
STA
MOV
STA
HLT

D, 00
Initialize register D to 00
A, 00
Initialize Accumulator content to 00
H, 8200
B, M
Get the first number in B - reg
H
C, M
Get the second number in C- reg.
B
Add content of A - reg to register B.
NEXT
Jump on no carry to NEXT.
D
Increment content of register D
C
Decrement content of register C.
LOOP
Jump on no zero to address
8252
Store the result in Memory
A, D
8253
Store the MSB of result in Memory
Terminate the program.

OBSERVATION:
Input:

FF (8200)
FF (8251)

Output:

01 (8252)
FE (8253)

4.

DIVISION OF TWO 8 BIT NUMBERS

ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register(B register).
3) Get the second data and load into Accumulator.
4) Compare the two numbers to check for carry.
5) Subtract the two numbers.
6) Increment the value of carry .
7) Check whether repeated subtraction is over and store the value of product and
carry in memory location.
8) Terminate the program.
PROGRAM:
LXI
H, 8300
MOV
B, M
MVI
C, 00
INX
H
MOV
A, M
NEXT: CMP
B
JC
LOOP
SUB
B
INR
C
JMP NEXT
LOOP: STA 8400
MOV
A, C
STA 8401
HLT

Get the dividend in B reg.


Clear C reg for qoutient
Get the divisor in A reg.
Compare A - reg with register B.
Jump on carry to LOOP
Subtract A reg from B- reg.
Increment content of register C.
Jump to NEXT
Store the remainder in Memory
Store the quotient in memory
Terminate the program.

OBSERVATION:
Input:

Output:

FF (8300)
FF (8301)
01 (8400) ---- Remainder
FE (8401) ---- Quotient

5. LARGEST NUMBER IN AN ARRAY OF DATA


ALGORITHM:
1) Load the address of the first element of the array in HL pair
2) Move the count to B reg.
3) Increment the pointer
4) Get the first data in A reg.
5) Decrement the count.
6) Increment the pointer
7) Compare the content of memory addressed by HL pair with that of A - reg.
8) If Carry = 0, go to step 10 or if Carry = 1 go to step 9
9) Move the content of memory addressed by HL to A reg.
10) Decrement the count
11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step.
12) Store the largest data in memory.
13) Terminate the program.
PROGRAM:
LXI
MOV
INX

H,8200
B,M
H

MOV

A,M

DCR

LOOP: INX

CMP

JNC

AHEAD

MOV

A,M

Set pointer for array


Load the Count
Set 1st element as largest data

Decrement the count

If A- reg > M go to AHEAD

Set the new value as largest

AHEAD:DCR

JNZ

LOOP

STA

8300

Repeat comparisons till count = 0


Store the largest value at 4300

HLT

OBSERVATION:
Input:

05 (8200) ----- Array Size


0A (8201)
F1 (8202)
1F (8203)
26 (8204)
FE (8205)

Output:
FE (8300)

6. SMALLEST NUMBER IN AN ARRAY OF DATA


ALGORITHM:
1) Load the address of the first element of the array in HL pair
2) Move the count to B reg.
3) Increment the pointer
4) Get the first data in A reg.
5) Decrement the count.
6) Increment the pointer
7) Compare the content of memory addressed by HL pair with that of A - reg.
8) If carry = 1, go to step 10 or if Carry = 0 go to step 9
9) Move the content of memory addressed by HL to A reg.
10) Decrement the count
11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step.
12) Store the smallest data in memory.
13) Terminate the program.
PROGRAM:
LXI
MOV
INX
MOV
DCR
LOOP:INX
CMP
JC
MOV
AHEAD:DCR
JNZ
STA
HLT

H,8200
Set pointer for array
B,M
Load the Count
H
Set 1st element as largest data
A,M
B
Decrement the count
H
M
If A- reg < M go to AHEAD
AHEAD
A,M
Set the new value as smallest
B
LOOP
Repeat comparisons till count = 0
8300
Store the largest value at 4300

OBSERVATION:
Input:

05 (8200) ----- Array Size


0A (8201)
F1 (8202)
1F (8203)
26 (8204)
FE (8205)

Output:
0A (8300)

7. ARRANGE AN ARRAY OF DATA IN ASCENDING ORDER

ALGORITHM:
1.
Initialize HL pair as memory pointer
2. Get the count at 4200 into C register
3.
Copy it in D register (for bubble sort (N-1) times required)
4. Get the first value in A register
5. Compare it with the value at next location.
6. If they are out of order, exchange the contents of A register and Memory
7. Decrement D register content by 1
8. Repeat steps 5 and 7 till the value in D- register become zero
9. Decrement C register content by 1
10. Repeat steps 3 to 9 till the value in C register becomes zero

PROGRAM:
LXI

H,8200

MOV

C,M

DCR

REPEAT: MOV D,C


LXI
LOOP:

SKIP:

H,8201

MOV A,M
INX

CMP

JC

SKIP

MOV

B,M

MOV

M,A

DCX

MOV

M,B

INX

DCR

JNZ

LOOP

DCR

JNZ

REPEAT

HLT
OBSERVATION:
Input:
8200 --05 (Array Size)
8201-- 05
8202-- 04
8203-- 03
8204-- 02
8205-- 01

Output:8201--01
8202--02
8203--03
8204--04
820505

8.ARRANGE AN ARRAY OF DATA IN DESCENDING ORDER


ALGORITHM:
1. Initialize HL pair as memory pointer
2. Get the count at 4200 into C register
3. Copy it in D register (for bubble sort (N-1) times required)
4. Get the first value in A register
5. Compare it with the value at next location.
6. If they are out of order, exchange the contents of A register and Memory
7. Decrement D register content by 1
8. Repeat steps 5 and 7 till the value in D- register become zero
9. Decrement C register content by 1
10. Repeat steps 3 to 9 till the value in C register becomes zero
PROGRAM:
LXI

H,4200

MOV C,M
DCR

REPEAT: MOV D,C


LXI
LOOP:

H,4201

MOV A,M

INX

CMP

JNC

SKIP

MOV B,M
MOV M,A
DCX

MOV M,B

SKIP:

INX

DCR

JNZ

LOOP

DCR

JNZ

REPEAT

HLT

9. HEX TO ASCII CONVERSION

ALGORITHM:
1. Load the given data in A- register and move to B register
2. Mask the upper nibble of the Hexa decimal number in A register
3. Call subroutine to get ASCII of lower nibble
4.

Store it in memory

5. Move B register to A register and mask the lower nibble


6. Rotate the upper nibble to lower nibble position
7. Call subroutine to get ASCII of upper nibble
8. Store it in memory
9. Terminate the program.

PROGRAM:
LDA

8200

MOV

B,A

ANI

0F

Mask Upper Nibble

CALL SUB1
STA

Get Hexa Data

Get ASCII code for upper nibble

8201

MOV A,B
ANI F0

Mask Lower Nibble

RLC
RLC
RLC
RLC
CALL
STA

SUB1 Get ASCII code for lower nibble


8202

HLT
SUB1:

CPI 0A

SKIP:

JC

SKIP

ADI

07

ADI

30

RET
OBSERVATION:
Input:
8200---E4(Hexa data)
Output:
8201---34(ASCII Code for 4)
8202---45(ASCII Code for E)

10. ASCII TO HEX CONVERSION

ALGORITHM:
1. Load the given data in A- register
.

2 Subtract 30 H from A register


3. Compare the content of A register with 0A H
4. If A < 0A H, jump to step6. Else proceed to next step.
5. Subtract 07 H from A register
6. Store the result
7. Terminate the program

PROGRAM:
LDA 8500
SUI 30
CPI 0A
JC

SKIP

SUI 07
SKIP:

STA 8501
HLT

OBSERVATION:
Input:
8500---31
Output:
8501---0B

11.

SQUARE OF A NUMBER USING LOOK UP TABLE

ALGORITHM:
1. Initialize HL pair to point Look up table
2. Get the data .
3. Check whether the given input is less than 9.
4.

If yes go to next step else halt the program

5. Add the desired address with the accumulator content


6. Store the result
PROGRAM:
LXI

H,8125

LDA

8150

CPI

0A

JC

AFTER

Initialsie Look up table address


Get the data
Check input > 9

MVI

A,FF

STA

8151

if yes error
Error Indication

HLT
AFTER: MOV

C,A

MVI

B,00

DAD

MOV

A,M

STA
HLT

4151

Add the desired Address

Store the result


Terminate the program

LOOKUP TABLE:
4125

01

4126

04

4127

09

4128

16

4129

25

4130

36

4131

49

4132

64

4133

81

OBSERVATION:
Input:
8125 : 05

Output:
4151 25 (Square)
Input : 4150: 11
Output:
4151: FF (Error Indication)

Anda mungkin juga menyukai