MICROPROCESSOR LAB

List Of Experiments

CYCLE-1:

1.  Addition of two 16-bit numbers using immediate addressing mode.

2.  Subtraction of two 16-bit numbers using immediate addressing mode.

3.  Addition of two 16-bit numbers using direct addressing mode.

4.  Subtraction of two 16-bit numbers using direct addressing mode.

5.  Arithmetic Operation:

a.  Multiword addition

b.  Multiword Subtraction

c.  Multiplication of two 16-bit numbers

d.  32bit/16 division

6.  Signed operation:

a.  Multiplication

b.  Division

7.  ASCII Arithmetic:

a.  AAA

b.  AAS

c.  AAM

d.  AAD

e.  DAA

f.  DAS

8.  Logic Operations:

a.  Shift right

b.  Shift left

c.  Rotate Right without carry

d.  Rotate left without carry

e.  Rotate Right with carry

f.  Rotate left with carry

g.  Packed to unpacked

h.  Unpacked to packed

i.  BCD to ASCII

j.  ASCII to BCD

9.  String Operation:

a.  String Comparison

b.  Moving the block of string from one segment to another segment.

c.  Sorting of string in ascending order

d.  Sorting of string in descending order

e.  Length of string

f.  Reverse of string

10.  Dos Function:

a.  Display a character

b.  Display a string

c.  Reading a Keyboard without echo

d.  Input a character

11.  Bios Function:

a. Set video mode

b. Cursor size

c. Keyboard shift status

d. Keyboard input with echo

12.  Modular Programs:

a.  Generation of fibonacci series

b.  Factorial of a given numbers

c.  Find largest number of a given ‘n’ numbers

d.  Find smallest number of a given ‘n’ numbers

e.  Display the system time

CYCLE-2

INTERFACING

13.  8279 Keyword Display-To display string of characters

14.  8255 PPI----ALP to generate

a.  Triangular wave

b.  Saw tooth wave

c.  Square wave

MICROCONTROLLER-8051

15.  Addition

16.  Subtraction

17.  Multiplication

18.  Division

19.  Reading and writing on a parallel port

20.  Swap & Exchange

21.  Timer mode operation

22.  Serial Communication implementation

Addition of two 16-bit numbers using DAM

Aim: Write an ALP in 8086 to perform the addition of two 16-bit numbers by using direct addressing mode.

Apparatus: 8086 Trainer Kit.

Program:

Mov ax, [1500]

Mov bx, [1502]

Add ax, bx

Mov [1504], ax

Hlt

Input:

Ax ß3322

[1500]ß22

[1501]ß33

Bxß5544

[1502]ß44

[1503]ß55

Output:

Axß8866

[1500]ß66

[1501]ß88

Result:

Thus the addition of two 16-bit numbers has been executed successfully using DAM and the result is verified.

Subtraction of two 16-bit numbers using DAM

Aim: Write an ALP in 8086 to perform the Subtraction of two 16-bit numbers by using direct addressing mode.

Apparatus: 8086 Trainer Kit.

Program:

Mov ax, [1500]

Mov bx, [1502]

Sub ax, bx

Mov [1504], ax

Hlt

Input:

Ax ß4433

[1500]ß33

[1501]ß44

Bxß2222

[1502]ß22

[1503]ß22

Output:

Axß2211

[1500]ß11

[1501]ß22

Result:

Thus the Subtraction of two 16-bit numbers has been executed successfully using DAM and the result is verified.

Addition of two 16-bit numbers using IAM

Aim: Write an ALP in 8086 to perform the addition of two 16-bit numbers by using Immediate addressing mode.

Apparatus: 8086 Trainer Kit.

Program:

Mov ax, 5611

Mov bx, 1234

Add ax, bx

Mov [1500], ax

Hlt

Input:

Ax ß5611

Bxß1234

Output:

Axß6845

[1500]ß45

[1501]ß68

Result:

Thus the addition of two 16-bit numbers has been executed successfully using IAM and the result is verified.

Subtraction of two 16-bit numbers using IAM

Aim: Write an ALP in 8086 to perform the addition of two 16-bit numbers by using Immediate addressing mode.

Apparatus: 8086 Trainer Kit.

Program:

Mov ax, 4567

Mov bx, 1111

Sub ax, bx

Mov [1500], ax

Hlt

Input:

Ax ß4567

Bxß1111

Output:

Axß3456

[1500]ß56

[1501]ß34

Result:

Thus the subtraction of two 16-bit numbers has been executed successfully using IAM and the result is verified.

1.  Arithmetic Operations

a) Multi Word addition

ASM code:

. Model small

. Stack

. Data

. Code

Mov AX, 0000h

Mov BX, 0000h

ADD AX, BX

Mov AX, 5678h

Mov BX, 1234h

ADC AX, BX

Mov DX, AX

INT 21h

END

INPUT 1: 56780000h

INPUT 2: 12340000h

OUTPUT: 68AD0000h

CX: 0000

DX: 68AD

RESULT:

Thus the program for addition of two double words has been executed successfully by using TASM & result is verified.

b) Multi Word subtraction

ASM code:

. Model small

. Stack

. Data

. Code

Mov AX, 0111h

Mov BX, 1000h

SUB AX, BX

MOV CX, AX

Mov AX, 5678h

Mov BX, 1234h

ADC AX, BX

Mov DX, AX

INT 21h

END

INPUT 1: 56780111h

INPUT 2: 12341000h

OUTPUT: 4443F111h

CX: F111 LSW of the result

DX: 68AD MSW of the result

RESULT:

Thus the program for subtraction of two double words has been executed successfully by using TASM & result is verified.

c) Multiplication of two 16-bit numbers

ASM code:

. Model small

. Stack

. Data

. Code

Mov AX, 1234h

Mov BX, 1234h

MUL BX

INT 21h

END

INPUT 1: 1234h

INPUT 2: 1234h

OUTPUT: 014B5A90h

CX: 5A90 LSW of the result

DX: 014B MSW of the result

RESULT:

Thus the program for multiplication of two 16-bit program executed successfully by using TASM & result is verified.

d) Multi Word Division (32-bit/16-bit)

ASM code:

. Model small

. Stack

. Data

. Code

Mov AX, 2786h

Mov BX, 2334h

Mov CX, 3552h

DIV CX

INT 21h

END

INPUT 1: 23342786h

INPUT 2: 3552h

OUTPUT: 303EA904h

AX: A904 LSW of the result

DX: 303E MSW of the result

RESULT:

Thus the multi word division of programs executed successfully by using TASM & result is verified.

3. Signed Operation

a.  Multiplication of two signed numbers

ASM code:

. Model small

. Stack

. Data

. Code

Mov AX, 8000h

Mov BX, 2000h

IMUL BX

INT 21H

END

INPUT 1:8000h

INPUT 2: 2000h

OUTPUT:

AXß 0000h

DXß F000h

RESULT:

Thus the program for multiplication of two signed numbers has been executed successfully by using TASM & result is verified.

b.  Division of two signed numbers

ASM code:

. Model small

. Stack

. Data

. Code

Mov AX, -0002h

Mov BL, 80h

IDIV BL

INT 21H

END

INPUT 1:AXß0002h

BXß 80h

OUTPUT:

AXß 00C0h

AlßC0h

Ahß 00h

RESULT:

Thus the program for division of two signed numbers has been executed successfully by using TASM & result is verified.

4. ASCII Arithmetic Operation

a)  AAA

ASM code:

. Model small

. Stack

. Data

. Code

Mov AL, 35h

Mov BL, 37h

ADD AL, BL

AAA

Int 21h

End

INPUT 1: 35h

INPUT 2: 37h

OUTPUT: AXß0102h

RESULT:

Thus the program for AAA has been executed successfully by using TASM & result is verified.

b)  AAS

ASM code:

. Model small

. Stack

. Data

. Code

Mov AL, 37h

Mov BL, 35h

SUB AL, BL

AAS

Int 21h

End

INPUT 1: 37h

INPUT 2: 35h

OUTPUT:

AXß0002h

RESULT:

Thus the program for AAS has been executed successfully by using TASM & result is verified.

c)  AAM

ASM code:

. Model small

. Stack

. Data

. Code

Mov AL, 06h

Mov BL, 09h

MUL BL

AAM

Int 21h

End

INPUT 1: 09h

INPUT 2: 06h

OUTPUT:

AXß0504h(un packed BCD)

RESULT:

Thus the program for AAM has been executed successfully by using TASM & result is verified.

d)  AAD

ASM code:

. Model small

. Stack

. Data

. Code

Mov AX, 1264h

Mov BL, 04h

DIV BL

AAD

Int 21h

End

INPUT 1: 1264h

INPUT 2: 04h

OUTPUT:

AXß0499

RESULT:

Thus the program for AAD has been executed successfully by using TASM & result is verified.

e)  DAA

ASM code:

. Model small

. Stack

. Data

. Code

Mov AL, 59h

Mov BL, 0935h

ADD AL, BL

DAA

Int 21h

End

INPUT 1: 59h

INPUT 2: 35h

OUTPUT:

AXß0094h

RESULT:

Thus the program for DAA has been executed successfully by using TASM & result is verified.

f)  DAS

ASM code:

. Model small

. Stack

. Data

. Code

Mov AL, 75h

Mov BL, 46h

SUBAL, BL

DAS

Int 21h

End

INPUT 1: 75h

INPUT 2: 46h

OUTPUT:

ALß29h

RESULT:

Thus the program for DAS has been executed successfully by using TASM & result is verified.

Logic Operation

Shift Right

ASM code:

. Model small

. Stack

. Data

. Code

Mov al, 46h

Mov cl, 04h

Shr al, cl

Int 21h

End

Input:

Alß46

Clß04

Output:

ß04h

RESULT:

Thus the program for Shift right operation has been executed successfully by using TASM & result is verified.

Shift Left

ASM code:

. Model small

. Stack

. Data

. Code

Mov al, 46h

Mov cl, 04h

Shl al, cl

Int 21h

End

Input:

Alß46

Clß04

Output:

ß60h

RESULT:

Thus the program for Shift left operation has been executed successfully by using TASM & result is verified.

Rotate Right Without Carry

ASM code:

. Model small

. Stack

. Data

. Code

Mov al, 68h

Mov cl, 04h

Ror al, cl

Int 21h

End

Input:

Alß68h

Clß04h

Output:

ß86h

RESULT:

Thus the program for rotate right without carry has been executed successfully by using TASM & result is verified.

Rotate Left Without carry

ASM code:

. Model small

. Stack

. Data

. Code

Mov al, 60h

Mov cl, 04h

Rol al, cl

Int 21h

End

Input:

Alß60h

Clß04h

Output:

ß06h

RESULT:

Thus the program for rotate left without carry has been executed successfully by using TASM & result is verified.

Rotate Right With Carry

ASM code:

. Model small

. Stack

. Data

. Code

Mov al, 56h

Mov cl, 03h

Rcr al, cl

Int 21h

End

Input:

Alß56h

Clß03h

Output:

Al= Bl

RESULT:

Thus the program for rotate right with carry has been executed successfully by using TASM & result is verified.

Rotate Left With Carry

ASM code:

. Model small

. Stack

. Data

. Code

Mov al, 56h

Mov cl, 03h

Rcl al, cl

Int 21h

End

Input:

Alß56h

Clß03h

Output:

Al=8Ah

RESULT:

Thus the program for rotate left with carry has been executed successfully by using TASM & result is verified.

Packed BCD to UNPACKED BCD Conversion

ASM Code:

. Model small

. Stack

. Data

. Code

Mov BL, 57h

Mov BH, 04h

Mov AL, BL

Mov CL, BH

SHL AL, CL

Mov CL, BH

ROR AL, CL

Mov DL, AL

Mov AL, BL

Mov CL, BH

SHR AL, CL

Mov DH, AL

INT 21H

END

Input:

BL (Packed BCD) =

Output:

DX (Unpacked BCD) =

RESULT:

Thus the program for conversion of packed to unpacked has been executed successfully by using TASM & result is verified.

UNPACKED BCD to Packed BCD Conversion

ASM Code:

. Model small

. Stack

. Data

. Code

Mov ax, 0207h

Mov al, 04h

Ror al, cl

Shr ax, cl

INT 21H

END

Input:

AXß0207(Unpacked BCD)

Output:

AXß0027(packed BCD)

RESULT:

Thus the program for conversion of unpacked to packed has been executed successfully by using TASM & result is verified.

ASCII to BCD

ASM Code:

. Model small

. Stack

. Data

. Code

Mov ax, 3638h

Mov bx, 3030h

Mov cl, 04h

Shl al, cl

Ror ax, cl

INT 21H

END

Input:

AXß3638h(Unpacked BCD)

Output:

AXß0068(packed BCD)

RESULT:

Thus the program for conversion of ASCII to BCD value has been executed successfully by using TASM & result is verified.

BCD to ASCII

ASM Code:

. Model small

. Stack

. Data

. Code

Mov AL, 57h

Mov CL, 04h

SHL AL, CL

ROR AL. 04H

XOR AL, 30H

MOV BL, AL

MOV AL, 57H

MOV CL, 04H

SHR AL, CL

XOR AL, 30H

MOV BH. AL

INT 21H

END

Input:

AL (BCD)ß

Output:

BX (ASCII)ß

RESULT:

Thus the program for conversion of BCD TO ASCII value has been executed successfully by using TASM & result is

STRING OPERATIONS

Strings Comparison:

ASM CODE:

. Model small

. Stack

. Data

Strg1 db ‘lab’,’$’

Strg 2 db ‘lab’, $’

Res db ‘strg are equal’,’$’

Res db ‘strg are not equal’,’$’

Count equ 03h

. Code

Mov ax, @data

Mov ds, ax

Mov es, ax

Lea si, strg1

Lea di, strg2

Cld

Rep cmpsb

Jnz loop1

Mov ah, 09h

Lea dx, res

Int 21h

Jmp a1

Loop1: mov ah, 09h

Lea dx, re1

Int 21h

A1: mov ah, 4ch

Int 21h

End

Input:

Strg1ß

Strg2ß

Output:

Result:

Thus the program of string comparison is executed successfully and the result is verified.

Data Transfer from one segment to another segment

ASM CODE:

. Model small

. Stack

. Data

String db’computer’

String 1 db8 dup (?)

. Code

Mov ax, @data

Mov ds, ax

Mov es, ax

Mov cl, 08h

Mov si, offset string

Mov di, offset string 1

Cld

Rep movsb

Int 21h

End

Input:

Output:

Result:

Thus the program to move a block of string from one memory location to another memory location is executed successfully.

Sorting a string in an ascending order

ASM code:

. Model small

. Stack

. Data

List1 db 53h, 10h, 24h, 12h

Count Equ, 04h

. Code

Mov AX, @data

Mov DS, AX

Mov Dx, Count-1

Again2: Mov CX, DX

Mov SI, offset List1

Again1: Mov AL, [SI]

CMP AL, [SI+1]

JL PR1

XCHG [SI+1], AL

XCHG [SI], AL

PR1: ADD SI, 01H

Loop Again1

DEC DX

JNZ Again2

Mov AH, 4ch

Int 21h

End

Input:

Enter string: 53h, 10h, 24h, 12h

Output:

Sorted String: 10h, 12h, 24h, 53h

Result:

Thus the program for sorting a string in an ascending order is executed successfully by TASM & result is verified.

Sorting a string in an descending order

ASM code:

. Model small

. Stack

. Data

List1 db 53h, 10h, 24h, 12h

Count Equ, 04h

. Code

Mov AX, @data

Mov DS, AX

Mov Dx, Count-1

Again2: Mov CX, DX

Mov SI, offset List1

Again1: Mov AL, [SI]

CMP AL, [SI+1]

JL PR1

XCHG [SI+1], AL

XCHG [SI], AL

PR1: ADD SI, 01H

Loop Again1

DEC DX

JNZ Again2

Mov AH, 4ch