Sie sind auf Seite 1von 86

EX.NO:1

DATE:

ARITHMETIC OPERATION

AIM:

To write an assembly language program for performing arithmetic operation using 8051 micro

controller.

APPARATUS REQUIRED:

8051 Microcontroller kit

Power supply

ALGORITHM:

ADDITION:

Step 1: Start the process by initializing the starting address.

Step 2:Move the data from DPTR to accumulator and increment the address.

Step 3:Move the data from accumulator to B register.

Step 4:Move the data from address to accumulator and increment the DPTR.

Step 5:Add the data from B register to accumulator and the result stored into the Accumulator. Step 6:Move the result in accumulator to corresponding value.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOWCHART FOR ADDITION:

Start
Start

Increment DPTR

FLOWCHART FOR ADDITION : Start Increment DPTR Move the DPTR value to Areg Add A and

Move the DPTR value to Areg

ADDITION : Start Increment DPTR Move the DPTR value to Areg Add A and B Store

Add A and B

Start Increment DPTR Move the DPTR value to Areg Add A and B Store result in

Store result in Areg

Move the DPTR value to Areg Add A and B Store result in Areg Increment DPTR

Increment DPTR

to Areg Add A and B Store result in Areg Increment DPTR Move the value A

Move the value A to DPTR

Stop
Stop

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR ADDITION:

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

   

4101

45

Mov DPTR,#4500

Initialize the memory location

4102

00

4103

 

E0

Movx A,@DPTR

Move the value from DPTR to A reg.

4104

 

A3

INC DPTR

Increment DPTR

4105

 

F5

 

Move the value of B to A.

4106

F0

Mov B,A

4107

 

E0

Movx A,@DPTR

Get the data and move to DPTR

4108

 

95

ADD A,B

Add A and B

4109

F0

410A

 

A3

INC DPTR

Increment DPTR

410B

 

F0

Movx @DPTR,A

Move the result to DPTR

410C

 

80

   

410D

HERE

FE

SJMP HERE

Short jump to end

OUTPUT:

OPERATION

ADDRESS

DATA

INPUT

4500

10

4501

10

OUTPUT

4502

20

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

SUBTRACTION:

ALGORITHM:

Step 1:Start the process by initializing the starting address.

Step 2:Move the data from DPTR to accumulator and increment the address.

Step 3:Move the data from accumulator to B register.

Step 4:Move the data from address to accumulator and increment the DPTR.

Step 5:Subtract the data from B register to accumulator and the result stored into the Accumulator. Step 6:Move the result in accumulator to corresponding value.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOWCHART FOR SUBTRACTION:

StartFLOWCHART FOR SUBTRACTION : Move the data into DPTR Move the DPTR value to Areg Move

Move the data into DPTR

FLOWCHART FOR SUBTRACTION : Start Move the data into DPTR Move the DPTR value to Areg

Move the DPTR value to Areg

: Start Move the data into DPTR Move the DPTR value to Areg Move the value

Move the value of A to B

DPTR Move the DPTR value to Areg Move the value of A to B Increment DPTR

Increment DPTR

DPTR value to Areg Move the value of A to B Increment DPTR Move the DPTR

Move the DPTR value to A reg.

value of A to B Increment DPTR Move the DPTR value to A reg. Subtract A

Subtract A and B

DPTR Move the DPTR value to A reg. Subtract A and B Store result in Areg

Store result in Areg

DPTR value to A reg. Subtract A and B Store result in Areg Increment DPTR Move

Increment DPTR

A reg. Subtract A and B Store result in Areg Increment DPTR Move the value A

Move the value A to DPTR

StopA and B Store result in Areg Increment DPTR Move the value A to DPTR Prepared

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR SUBTRACTION

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

 

Initialize the memory location

4101

45

Mov DPTR,#4500

4102

00

4103

 

E0

Movx A,@DPTR

Mov the value from DPTR to A reg.

4104

 

A3

INC DPTR

Increment DPTR

4105

 

F5

   

4106

F0

Mov B,A

Move the value of B to A.

4107

 

E0

Movx A,@DPTR

Get the data and move to DPTR

4108

 

95

SUBB A,B

Subtract B from A

4109

F0

410A

 

A3

INC DPTR

Increment DPTR

410B

 

F0

Movx @DPTR,A

Move the result to DPTR

   

80

   

410C

HERE

FE

SJMP HERE

Short jump to end

410D

OUTPUT:

OPERATION

ADDRESS

DATA

INPUT

4500

20

4501

10

OUTPUT

4502

10

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

MULTIPLICATION:

ALGORITHM:

Step 1:Start the process by initializing the starting address.

Step 2:Move the data from DPTR to accumulator and increment the address.

Step 3:Move the data from accumulator to B register.

Step 4:Move the data from address to accumulator and increment the DPTR.

Step 5:Multiply the data from B register to accumulator and the result stored into the Accumulator. Step 6:Move the result in accumulator to corresponding value.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOWCHART FOR MULTIPLICATION:

StartFLOWCHART FOR MULTIPLICATION : Move the data into DPTR Move the DPTR value to Areg Move

Move the data into DPTR

FLOWCHART FOR MULTIPLICATION : Start Move the data into DPTR Move the DPTR value to Areg

Move the DPTR value to Areg

: Start Move the data into DPTR Move the DPTR value to Areg Move the value

Move the value of A to B

DPTR Move the DPTR value to Areg Move the value of A to B Increment DPTR

Increment DPTR

DPTR value to Areg Move the value of A to B Increment DPTR Move the DPTR

Move the DPTR value to Areg

value of A to B Increment DPTR Move the DPTR value to Areg Multiply A and

Multiply A and B

Increment DPTR Move the DPTR value to Areg Multiply A and B Store result in Areg

Store result in Areg

the DPTR value to Areg Multiply A and B Store result in Areg Increment DPTR Move

Increment DPTR

to Areg Multiply A and B Store result in Areg Increment DPTR Move the value A

Move the value A to DPTR

StopA and B Store result in Areg Increment DPTR Move the value A to DPTR Prepared

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR MULTIPLICATION

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

   

4101

45

Mov DPTR,#4500

Initialize the memory location

4102

00

4103

 

E0

Movx A,@DPTR

Mov the value from DPTR to A reg.

4104

 

A3

INC DPTR

Increment DPTR

4105

 

F5

   

4106

F0

Mov B,A

Move the value of B to A.

4107

 

E0

Movx A,@DPTR

Get the data and move to DPTR

4108

 

A4

MUL A,B

Multiply a and b

4109

 

A3

INC DPTR

Increment DPTR

410A

 

F0

Movx @DPTR,A

Move the result to DPTR

   

80

   

410B

HERE

FE

SJMP HERE

Short jump to end

410C

OUTPUT:

OPERATION

ADDRESS

DATA

INPUT

4500

14

4501

25

OUTPUT

4502

E4

4503

02

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

DIVISION:

ALGORITHM:

Step 1:Start the process by initializing the starting address.

Step 2:Move the data from DPTR to accumulator and increment the address.

Step 3:Move the data from accumulator to B register.

Step 4:Move the data from address to accumulator and increment the DPTR.

Step 5:Divide the data from B register to accumulator and the result stored into the Accumulator. Step 6:Move the result in accumulator to corresponding value.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOWCHART FOR DIVISION:

StartFLOWCHART FOR DIVISION : Move the data into DPTR Move the DPTR value to Areg Move

Move the data into DPTR

FLOWCHART FOR DIVISION : Start Move the data into DPTR Move the DPTR value to Areg

Move the DPTR value to Areg

: Start Move the data into DPTR Move the DPTR value to Areg Move the value

Move the value of A to B

DPTR Move the DPTR value to Areg Move the value of A to B Increment DPTR

Increment DPTR

DPTR value to Areg Move the value of A to B Increment DPTR Move the DPTR

Move the DPTR value to Areg

value of A to B Increment DPTR Move the DPTR value to Areg Divide A and

Divide A and B

B Increment DPTR Move the DPTR value to Areg Divide A and B Store result in

Store result in Areg

the DPTR value to Areg Divide A and B Store result in Areg Increment DPTR Move

Increment DPTR

to Areg Divide A and B Store result in Areg Increment DPTR Move the value A

Move the value A to DPTR

StopA and B Store result in Areg Increment DPTR Move the value A to DPTR Prepared

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR DIVISION:

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

   

4101

45

Mov

DPTR,#4500

Initialize the memory location

4102

00

 

4103

 

E0

Movx A,@DPTR

Mov the value from DPTR to A reg.

4104

 

A3

INC

DPTR

Increment DPTR

4105

 

F5

   

Mov

B,A

Move the value of B to A.

4106

F0

 

4107

 

E0

Movx A,DPTR

Get the data and move to DPTR

4108

 

A4

DIV

A,B

Divide a by b

4109

 

A3

INC

DPTR

Increment DPTR

410A

 

F0

Movx @DPTR,A

Move the result to DPTR

   

80

   

410B

HERE

FE

SJMP HERE

Short jump to end

410C

OUTPUT:

 

OPERATION

ADDRESS

DATA

INPUT

4500

06

4501

02

OUTPUT

4502

03

RESULT:

Thus the above program for Arithmetic Operations using 8051 Microcontroller was successfully executed and Output was verified.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

EX.NO:2

DATE:

LOGICAL OPERATION

AIM:

To write an assembly language program for performing logical operation using 8051 micro controller.

AND OPERATION:

ALGORITHM:

Step 1:Start the process by initializing the starting address.

Step 2:Move the data from DPTR to accumulator

Step 3:Perform AND operation with A and immediate data.

Step 4:Increment DPTR.

Step 5: Move the data from address to accumulator to DPTR.

Step 6:Stop the process.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOWCHART FOR AND OPERATION:

StartFLOWCHART FOR AND OPERATION : Initializing DPTR Move data from DPTR to acc Perform AND operation

Initializing DPTR

FLOWCHART FOR AND OPERATION : Start Initializing DPTR Move data from DPTR to acc Perform AND

Move data from DPTR to acc

: Start Initializing DPTR Move data from DPTR to acc Perform AND operation A with immediate

Perform AND operation A with immediate data

from DPTR to acc Perform AND operation A with immediate data Store the result Increment DPTR

Store the result

Perform AND operation A with immediate data Store the result Increment DPTR Move data A to

Increment DPTR

A with immediate data Store the result Increment DPTR Move data A to DPTR Stop Prepared

Move data A to DPTR

Stopimmediate data Store the result Increment DPTR Move data A to DPTR Prepared by Mr. J.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR AND OPERATION

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

 

Initialize the memory location

4101

45

Mov DPTR,#4500

4102

00

4103

 

E0

Movx A,@DPTR

Mov the value from DPTR to A reg.

4104

 

54

   

4105

20

ANL A,#20

Perform AND operation.

4106

 

A3

INC DPTR

Increment DPTR

4107

 

F0

Movx @DPTR,A

Move the data A to DPTR

4108

 

80

   

4109

HERE

FE

SJMP HERE

Short jump here

OUTPUT:

OPERATION

INPUT

OUTPUT

ADDRESS

4500

4501

DATA

10

00

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

OR OPERATION:

ALGORITHM

Step 1:Start the process by initializing the starting address.

Step 2:Move the data from DPTR to accumulator

Step 3:Perform OR operation with A and immediate data.

Step 4:Increment DPTR.

Step 5: Move the data from address to accumulator to DPTR.

Step 6:Stop the process.

FLOWCHART FOR AND OPERATION:

StartStep 6: Stop the process. FLOWCHART FOR AND OPERATION : Initializing DPTR Move data from DPTR

Initializing DPTR

FLOWCHART FOR AND OPERATION : Start Initializing DPTR Move data from DPTR to Acc Perform OR

Move data from DPTR to Acc

: Start Initializing DPTR Move data from DPTR to Acc Perform OR operation A with immediate

Perform OR operation A with immediate data

from DPTR to Acc Perform OR operation A with immediate data Store the result Increment DPTR

Store the result

Perform OR operation A with immediate data Store the result Increment DPTR Move data A to

Increment DPTR

A with immediate data Store the result Increment DPTR Move data A to DPTR Stop Prepared

Move data A to DPTR

Stopimmediate data Store the result Increment DPTR Move data A to DPTR Prepared by Mr. J.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR OR OPERATION

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

 

Initialize the memory location

4101

45

Mov DPTR,#4500

4102

00

4103

 

E0

Movx A,@DPTR

Mov the value from DPTR to A reg.

4104

 

54

   

4105

20

ORL A,#20

Perform OR operation.

4106

 

A3

INC DPTR

Increment DPTR

4107

 

F0

Movx @DPTR,A

Move the data A to DPTR

4108

 

80

   

4109

HERE

FE

SJMP HERE

Short jump here

OUTPUT:

OPERATION

INPUT

OUTPUT

ADDRESS

4500

4501

DATA

10

30

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

X-OR OPERATION:

ALGORITHM:

Step 1:Start the process by initializing the starting address.

Step 2:Move the data from DPTR to accumulator

Step 3:Perform X-OR operation with A and immediate data.

Step 4:Increment DPTR.

Step 5: Move the data from address to accumulator toDPTR.

Step 6:Stop the process.

FLOWCHART FOR AND OPERATION:

StartStep 6 :Stop the process. FLOWCHART FOR AND OPERATION : Initializing DPTR Move data from DPTR

Initializing DPTR

FLOWCHART FOR AND OPERATION : Start Initializing DPTR Move data from DPTR to Acc Perform X-OR

Move data from DPTR to Acc

: Start Initializing DPTR Move data from DPTR to Acc Perform X-OR operation A with immediate

Perform X-OR operation A with immediate data

DPTR to Acc Perform X-OR operation A with immediate data Store the result Increment DPTR Move

Store the result

X-OR operation A with immediate data Store the result Increment DPTR Move data A to DPTR

Increment DPTR

A with immediate data Store the result Increment DPTR Move data A to DPTR Stop Prepared

Move data A to DPTR

Stopimmediate data Store the result Increment DPTR Move data A to DPTR Prepared by Mr. J.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR X-OR OPERATION

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

 

Initialize the memory location

4101

45

Mov DPTR,#4500

4102

00

4103

 

E0

Movx A,@DPTR

Mov the value from DPTR to A reg.

4104

 

54

   

4105

20

XRL A,#20

Perform XRL operation.

4106

 

A3

INC DPTR

Increment DPTR

4107

 

F0

Movx @DPTR,A

Move the data A to DPTR

4108

 

80

   

4109

HERE

FE

SJMP HERE

Short jump here

OUTPUT:

 

OPERATION

ADDRESS

DATA

INPUT

4500

10

OUTPUT

4501

30

RESULT:

Thus the above program for Logical Operations using 8051 Microcontroller was successfully executed and Output was verified.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

EX.NO:3

DATE:

SQUARE& CUBE OF A NUMBER

AIM:

To write an assembly language program to find square and cube of a number using 8051 micro controller.

APPARATUS REQUIRED:

8051microcontroller.

Power supply

SQUARE OF A NUMBER

ALGORITHM:

Step 1:Start the process by initializing the starting address.

Step 2:Transfer the data to ax register.

Step 3:Store the data from ax register to data segment.

Step 4:Transfer the data to source in a register.

Step 5:Move the no of cl register.

Step 6:Multiply BL with ax value

Step 7:Move the data in Al register to source center.

Step 8:Decrement cl.

Step 9: Stop the process.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOWCHART FOR SQUARE OF A NUMBER:

StartFLOWCHART FOR SQUARE OF A NUMBER : Move the data to DPTR Move the DPTR value

Move the data to DPTR

FOR SQUARE OF A NUMBER : Start Move the data to DPTR Move the DPTR value

Move the DPTR value of A

: Start Move the data to DPTR Move the DPTR value of A Move the content

Move the content of A & B

DPTR Move the DPTR value of A Move the content of A & B Multiply the

Multiply the two values

of A Move the content of A & B Multiply the two values Increment DPTR Move

Increment DPTR

content of A & B Multiply the two values Increment DPTR Move the A register value

Move the A register value of DPTR

two values Increment DPTR Move the A register value of DPTR Move the data from B

Move the data from B register from A

StopMove the A register value of DPTR Move the data from B register from A Prepared

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

   

4101

45

MOV DPTR,#4500

Move 4500 to DPTR

4102

00

4103

 

E0

MOVX A,@DPTR

MOVE THE CONTROL AT DPTR TO A

4104

 

A3

INC DPTR

INCREMENT DPTR

4105

 

F5

   

4106

F0

MOV B,A

MOVE A TO B

4107

 

A4

MUL AB

MULTIPLY A&B

4108

 

F0

MOVX@DPTR,A

MOVE THE VALUE OF A &DPTR

4109

 

A3

INC DPTR

INCREMENT DPTR

410A

 

E5

   

410B

F0

MOV A,B

MOVE B TO A

411C

 

F0

MOVX@DPTR,A

MOVE THE VALUE AT A OF DPTR

411D

 

80

   

411E

HERE

FE

SJMP HERE

Short jump here

OUTPUT

OPERATION

ADDRESS8

DATA

INPUT

4500

02

OUTPUT

4501

04

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

CUBE OF A NUMBER

ALGORITHM:

Step 1:Start the process by initializing the starting address.

Step 2:Move the data from DPTR to ac.

Step 3:Move the data from accumulator to b reg.

Step 4:Multiply data & data2 and store the value.

Step 5:Move the data from accumulator data to a reg.

Step 6:Move the data from DPTR to register.

Step 7:Move the data from register.

Step 8: Multiply data1 and data2 store the value, IncrementDPTR, Mov A register to DPTR, Stop the process.

FLOW CHART FOR CUBE OF A NUMBER:

Start
Start

Move the data to DPTR

FLOW CHART FOR CUBE OF A NUMBER: Start Move the data to DPTR To find a

To find a square of a number

Start Move the data to DPTR To find a square of a number Move the data

Move the data to DPTR

to DPTR To find a square of a number Move the data to DPTR Multiply with

Multiply with square of a number

Move the data to DPTR Multiply with square of a number Move the value to DPTR

Move the value to DPTR

Stop
Stop

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

Address

Label

Opcode

Mnemonics

comment

4100

 

90

   

4101

45

MOV DPTR,#4500

Move 4500 to DPTR

4102

00

4103

 

E0

MOVX A,@DPTR

MOVE THE CONTROL AT DPTR TO A

4104

 

F5

MOV B,A

Move A TO B

4105

 

F0

   

4106

A4

MUL AB

MULTIPLY A AND B

4107

 

F8

MOV R0,A

Move A TO R0

4108

 

E0

 

MOVE THE VALUE DPTR TO

MOVX A,@DPTR

A

4109

 

F5

MOV B,A

MOV A VALUE TO B

410A

 

F0

MOV A,R0

MOVE R0 TO A

410B

 

E8

MUL AB

MULTIPLY A AND B

410C

 

A4

INC DPTR

INCREMENT DPTR

410D

       

A3

MOVE THE VALUE A TO

410E

MOVE @DPTR,A

F0

DPTR

410F

HERE

80

SJMP HERE

SJMP HERE

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

OUTPUT

OPERATION

ADDRESS

DATA

INPUT

4500

02

OUTPUT

4501

08

RESULT

Thus the above program for square and cube of a number using 8051 was executed successfully and output verified.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

EX.NO:4

DATE:

1’s AND 2’s COMPLEMENT

AIM:

To write an assembly language program to find 1’s and 2’s complement of a given

numbers by using 8051 microcontroller.

APPARTUS REQUIRED:

8051 Micro controller kit.

Power supply

ALGORITHM:

2’s COMPLEMENT

Step 1: start the process. Step 2: move the value from DPTR to accumulator. Step 3: Take complement of the given number. Step 4: add 1 to the above result Step 5: stop the process

FLOW CHART FOR 2’s COMPLEMENT:

Start
Start

Move the data to DPTR

CHART FOR 2’s COMPLEMENT : Start Move the data to DPTR Take Complement of a Number

Take Complement of a Number

: Start Move the data to DPTR Take Complement of a Number Add 1 to the

Add 1 to the above result

Stop
Stop

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR 2’s COMPLEMENT

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

   

90

   

4101

45

MOV DPTR,#4500

Move 4500 to DPTR

4102

00

4103

   

E0

MOVX A,@ DPTR

Move the content at DPTR to A

4104

   

F4

CPL A

Complement The value of a

4105

 

24A

ADD A,# 01

Add o1 with AL

4106

 

01

4107

   

A3

INC DPTR

Increment DPTR

4108

   

F0

Movx @DPTR,A

Move the value of A at DPTR

4109

   

80

   

410A

HERE

FE

SJMP HERE

Short jumb here

OUTPUT:

OPERATION

   

ADDRESS

DATE

INPUT

   

4500

02

OUTPUT

   

4501

FE

1’S COMPLEMENT

ALGORITHM:

Step 1:start the process.

Step 2: move the value from DPTR to accumulator.

Step 3: Take complement of the given number.

Step 4: stop the process

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOW CHART FOR 1’s COMPLEMENT:

Start
Start

Move the data to DPTR

CHART FOR 1’s COMPLEMENT : Start Move the data to DPTR Take Complement of a Number

Take Complement of a Number

: Start Move the data to DPTR Take Complement of a Number Add 1 to the

Add 1 to the above result

Stop
Stop

PROGRAM FOR 1’s COMPLEMENT

ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENT

4100

 

90

   

4101

45

Initialize the locater

4102

00

MOV DPTR,# 4500

4103

 

E0

MOVX A,@ DPTR

Get the data accumulator

4104

 

F4

CPL A

Take compliment of the number

4105

 

A3

INC DPTR

Increment DPTR

4106

 

F0

MOVX @DPTR,A

Get the data in accumulator

   

80

   

4107

HERE

FE

SJMP HERE

Short jump here

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

OUTPUT:

OPERATION

ADDRESS

DATE

INPUT

4500

03

OUTPUT

4501

FC

RESULT:

Thus the above program for 1’s and 2’s complement was successfully executed and output verified.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

EX.NO:5

DATE:

SORTING OF AN ARRAY

AIM:

To write an assembly language program to find the largest and smallest number using 8051 microcontroller kit

APPARATUS REQUIRED:

8051microcontroller.

Power supply

LARGEST NUMBER ALGORITHM:

Step1:Start the program.

Step2: Move the content

from

DPTR to the location 5000.

Step 3: Move

the

content

from

DPTR accumulator,

Step4: Increment

from

DPTR.

Step5: Carry

jump

not

equal

to the accumulator.

Step6: Decrement

jump

not equal

from register to the up.

Step7: Stop the process

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOW CHART FOR LARGEST NUMBER:

Start
Start

Move the content the location

FOR LARGEST NUMBER: Start Move the content the location Move the content register r2 Move the

Move the content register r2

Move the content the location Move the content register r2 Move the content from the DPTR

Move the content from the DPTR to

the content register r2 Move the content from the DPTR to Increment DPTR Move the DPTR

Increment DPTR

register r2 Move the content from the DPTR to Increment DPTR Move the DPTR Carry jump

Move the DPTR

the content from the DPTR to Increment DPTR Move the DPTR Carry jump not event from

Carry

jump

not event from directory

DPTR Move the DPTR Carry jump not event from directory Move the content from the directory

Move the content from the directory

Stopjump not event from directory Move the content from the directory Prepared by Mr. J. Satheesh

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR LARGEST NUMBER

ADDRESS

LABEL

OP CODE

MNEMONICS

COMMENT

4100

 

90

   

4101

45

MOV DPTR,#5000

Move 5000 to DPTR

4102

50

4103

 

C3

CLR C

Clear carry

4104

 

7a

MOV r2,#03h

Move r2

4105

2q

4106

 

E0

MOVX a,@ DPTR

MOV a content of DPTR

4107

 

F5

MOV 30h,a

Move the content From a to 30 l1

4108

30

4109

 

A3

INC DPTR MOVX a,@ DPTR

Increment DPTR Move the content DPTR

410a

E0

410b

 

85

 

Compare Jumb not Equal to

410c

30

CJNE,30h

410d

FD

410e

 

04

SJMP NEXT

Start jump & next

4110

 

F4

   

4111

DN

Fe

JC NEXT

Jump if carry to next

4112

 

F5

MOV 30h,a

Move a to 30

4113

36

4114

 

DA

 

Decrement jump Set to zero

4115

F3

DJNI R1,up

4116

 

A3

INC DPTR

Increment DPTR

4117

 

E5

MOV A,30h

Move the content of 30h to A

4118

30

4119

 

F0

MOVX @ DPTR ,a

Move A to DPTR

411A

 

80

   

411B

FE

SJMP HERE

Short jump here

OUTPUT:

OPERATION

ADDRESS

DATA

 

5000

05

INPUT

5001

FA

5002

91

5003

B2

OUTPUT

5004

FA

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

SMALLEST NUMBER ALGORITHM:

Step1:Start the program. Step2: Move the content fromDPTR to the location 5000. Step 3: Move the content from DPTR accumulator,

Step4: Increment from DPTR.

Step5: Carry jump not equal to the accumulator.

Step6: Decrement jump not equal from register to the up.

Step7: Stop the process

FLOW CHART FOR SMALLEST NUMBER

Start

Stop the process FLOW CHART FOR SMALLEST NUMBER Start Move the content the location Move the

Move the content the location

FOR SMALLEST NUMBER Start Move the content the location Move the content register r2 Move the

Move the content register r2

Move the content the location Move the content register r2 Move the content from the DPTR

Move the content from the DPTR to

the content register r2 Move the content from the DPTR to Increment DPTR Move the DPTR

Increment DPTR

register r2 Move the content from the DPTR to Increment DPTR Move the DPTR Carry jump

Move the DPTR

the content from the DPTR to Increment DPTR Move the DPTR Carry jump not event from

Carry

jump

not event from directory

DPTR Move the DPTR Carry jump not event from directory Move the content from the directory

Move the content from the directory

Prepared by Start
Prepared by
Start

Mr. J. Satheesh Kumar,

AP / ECE / HICET

PROGRAM FOR SMALLEST NUMBER

ADDRESS

LABEL

OP CODE

MNEMONICS

COMMENT

4100

 

90

   

4101

45

MOV DPTR,#5000

Move 5000 to DPTR

4102

50

4103

 

C3

CLR C

Clear carry

4104

 

7a

MOV r2,#03h

Move r2

4105

2q

4106

 

E0

MOVX a,@ DPTR

MOV a content of DPTR

4107

 

F5

MOV 30h,a

Move the content From a to 30 l1

4108

30

4109

 

A3

INC DPTR MOVX a,@ DPTR

Increment DPTR Move the content DPTR

410a

E0

410b

 

85

 

Compare Jumb Not Equal to

410c

30

CJNE,30h

410d

FD

410e

 

04

SJMP NEXT

Start jump & next

4110

 

F4

 

Jump if carry is zero next

4111

DN

Fe

JNC NEXT

4112

 

F5

MOV 30h,a

Move a to 30

4113

36

4114

 

DA

 

Decrement jump Set to zero

4115

F3

DJNI R1,up

4116

 

A3

INC DPTR

Increment DPTR

4117

 

E5

MOV A,30h

Move the content of 30h to A

4118

30

4119

 

F0

MOVX @ DPTR ,a

Move A to DPTR

411A

 

80

   

411B

FE

SJMP HERE

Short jump here

OUTPUT:

OPERATION

ADDRESS

DATA

 

5000

05

INPUT

5001

FA

5002

91

5003

B2

OUTPUT

5004

05

RESULT:

Thus the above program for largest and smallest number was successfully executed and the output was verified.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

EX NO:6

SORTING

DATE :

AIM

To arrange the numbers in ascending order using 8051 micro controller kit.

APPARTUS REQUIRD

8051Microcontroller kit.

Power supply

ASSENDING ORDER

ALGORITHM

Step 1:Start the process

Step 2:Enter the input values to DPTR.

Step 3:Using 2 looping statements to arrange the input values to ascending order.

Step 4:Execute the program to arrange input number.

Step 5:Stop the process.

FLOW CHART FOR ASSENDING ORDER

StartStep 5: Stop the process. FLOW CHART FOR ASSENDING ORDER Enter input values to DPTR Using

Enter input values to DPTR

CHART FOR ASSENDING ORDER Start Enter input values to DPTR Using 2 loops to arrange the

Using 2 loops to arrange the input values

values to DPTR Using 2 loops to arrange the input values Execute the program Prepared by

Execute the program

Prepared by Mr. J. Satheesh Kumar, Stop AP / ECE / HICET
Prepared by
Mr. J. Satheesh Kumar,
Stop
AP / ECE / HICET

PROGRAM FOR ASSENDING ORDER

ADDERS

LABEL

OPCODE

MNEMONICS

COMMENTS

4100

 

7C

MOV R4,#04

move immediate value 04 to r4

4101

04

4102

AGAIN

7B

MOV R3,#04

move immediate value 04 to r3

4103

04

4104

 

96

 

move immediate value 4500 to DPTR

4105

45

MOV DPTR,#4500

4106

00

4107

 

C3

CLRC

clear carry

4108

 

E0

MOVX A,@DPTR

move DPTR to a

4109

 

EA

MOV R1,A

move value a to r1

410A

 

A3

INC DPTR

increment DPTR

410B

 

E0

MOVX A,@DPTR

move DPTR to a

410C

 

99

SUBB A,R1

subtract a,r1

410D

 

50

   

410E

FE

JNC SKIP

jump on not carry

410F

 

E0

MOVX A,@DPTR

move DPTR value

4110

 

F8

SUB A,R1

subtract a,r1

4111

 

15

INC SKIP

jump on next

4112

82

4113

 

E0

MOVX

A,@DPTR

move DPTR to a

4114

 

08

XCH A,R0

exchange a,r0

4115

 

F0

MOVX @DPTR,A

move a to DPTR

4116

 

05

   

4117

82

INC DPL

increment DPTR

4118

 

E8

MOV A,R0

move r0 to a

4119

 

F0

MOV X @DPTR,A

move a to DPTR

411A

SKIP

DC

DJNZ R3,UP

decrement jump non zero

411B

FC

411D

 

DC

DJNZ R4,AGAIN

decrement jump

411E

E4

non zero

   

80

   

411F

HERE

FE

SJMP HERE

start jump here

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

OUTPUT

OPERATION

ADDRESS

DATA

 

4500

06

4501

04

INPUT

4502

08

4503

03

4504

09

 

4500

03

4501

04

OUTPUT

4502

06

4503

08

4504

09

DESCENDING ORDER ALGORITHM

Step 1:Start the process

Step 2:Enter the input values to DPTR.

Step 3:Using 2 looping statements to arrange the input values to descending order.

Step 4:Stop the process.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOW CHART FOR DECENDING ORDER

Start

FLOW CHART FOR DECENDING ORDER Start Enter input values to DPTR Using 2 loops to arrange

Enter input values to DPTR

CHART FOR DECENDING ORDER Start Enter input values to DPTR Using 2 loops to arrange the

Using 2 loops to arrange the input values

values to DPTR Using 2 loops to arrange the input values Execute the program Stop PROGRAM

Execute the program

Stop2 loops to arrange the input values Execute the program PROGRAM FOR DECENDING ORDER ADDERS LABEL

PROGRAM FOR DECENDING ORDER

ADDERS

LABEL

OPCODE

MNEMONICS

COMMENTS

4100

 

7C

MOV R4,#04

move immediate value 04 to r4

4101

04

4102

AGAIN

7B

MOV R3,#04

move immediate value 04 to r3

4103

04

4104

 

96

 

move immediate value 4500 to DPTR

4105

45

MOV DPTR,#4500

4106

00

4107

 

C3

CLRC

clear carry

4108

 

E0

MOVX A,@DPTR

move DPTR to A

4109

 

EA

MOV R1,A

move value A to R1

410A

 

A3

INC DPTR

increment DPTR

410B

 

E0

MOVX A,@DPTR

move DPTR to A

410C

 

99

SUBB A,R1

subtract A,R1

410D

 

50

   

410E

FE

JC SKIP

jump on not carry

410F

 

E0

MOVX A,@DPTR

move DPTR value to A

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

4110

 

F8

MOV R0,A

move A to R1

4111

 

15

DEC DPL

decrement DPL

4112

82

4113

 

E0

MOVX

A,@DPTR

move DPTR to a

4114

 

08

XCH A,R0

exchange a,r0

4115

 

F0

MOVX @DPTR,A

move a to DPTR

4116

 

05

   

4117

82

INC DPTR

increment DPL

4118

 

E8

MOV A,R0

move R0 to a

4119

 

F0

MOV X @DPTR,A

move a to DPTR

411A

SKIP

DC

DJNZ R3,UP

decrement jump non zero

411B

FC

411D

 

DC

DJNZ R4,AGAIN

decrement jump

411E

E4

non zero

   

80

   

411F

HERE

FE

SJMP HERE

start jump here

OUTPUT

OPERATION

ADDRESS

DATA

 

4500

05

4501

07

INPUT

4502

06

4503

08

4504

09

 

4500

09

4501

08

OUTPUT

4502

07

4503

06

4504

05

RESULT

Thus the above program for ascending order and descending order was executed successfully and the output was verified.

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

EX.NO:7

DATE:

MATRIX AND ADDITION AND SUBTRACTION

AIM:

To write an assembly language program for matrix addition and subtraction using 8051 micro controller.

APPARATUS REQUIRED:

8051microcontroller.

Power supply

MATRIX ADDITION

ALGORITHM:

Step1: Start the program.

Step2: Declare the value for the data pointer for higher and lower bit.

Step 3:Get the value in address 4500 and move to the accumulator,

Step4: Move the value in 4500 to r0.

Step5: Get the value in address 4600 and move the value to the accumulator.

Step6: Add the value in R0 and accumulator.

Step7: Store the value in the address 4700

Step8: Increment DPL.

Step 9:Stop the process

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

FLOW CHART FOR MATRIX ADDITION:

Start FLOW CHART FOR MATRIX ADDITION: Get input values on matrix 1 Get input values on matrix

Get input values on matrix 1

FOR MATRIX ADDITION: Start Get input values on matrix 1 Get input values on matrix 2

Get input values on matrix 2

Get input values on matrix 1 Get input values on matrix 2 Add Matrix 1 &

Add Matrix 1 & Matrix 2

1 Get input values on matrix 2 Add Matrix 1 & Matrix 2 Store result in

Store result in Matrix 3

Stopon matrix 2 Add Matrix 1 & Matrix 2 Store result in Matrix 3 Prepared by

Prepared by Mr. J. Satheesh Kumar, AP / ECE / HICET

PROGRAM FOR MATRIX ADDITION: