You are on page 1of 3

BHILAI INSTITUTE OF TECHNOLOGY, DURG (C.G.

)
(SETH BALKRISHAN MEMORIAL)

BHILAI HOUSE, G.E. ROAD, DURG (C.G.)-491001


Department of Electronics & Telecommunication
Engineering
B.E 7th Sem

Sub Code & Name :328713(28)Microcontroller & Embedded Systems Lab.


Roll No: 111

Experiment No: 15
Date: 8th SEPT 2010
Aim: Write a microcontroller 8051 program to calculate square root of 8 bit number.

Requirements: 8051IDE Software, Sim8051 Software, PC.

PROGRAM:

MOV A,30H
MOV B,#01H
MOV R3,A
BACK:MOV R2,B
DIV AB
MOV B,R2
CJNE A,B,L1
SJMP END
L1:MOV A,R3
INC B
CJNE R2,#10H,BACK
END:SJMP END

K.Uma Submission Date: 1


(Prof. Incharge)
15TH SEPT 2010
BHILAI INSTITUTE OF TECHNOLOGY, DURG (C.G.)
(SETH BALKRISHAN MEMORIAL)

BHILAI HOUSE, G.E. ROAD, DURG (C.G.)-491001


Department of Electronics & Telecommunication
Engineering
B.E 7th Sem

Sub Code & Name :328713(28)Microcontroller & Embedded Systems Lab.


Roll No: 111

Program and Source Code:


Address Hex object code Mnemonics Comments

Opcode Operand

0000 E5 30 MOV A,#30H Initialize accumulator by value


30H
0002 75 F0 0A MOV B,#01H Initialize reg B by value 01H

0005 FB MOV R3,A Copy the content of


accumulator to R3
0006 AA F0 MOV R2,B Copy the content of register B
to R3
0008 84 DIV AB Divide value of B from A

0009 8A F0 MOV B,R2 Copy the content of R2 to


register B
000B B5 F0 02 CJNE A,B,0010H Compare A and B and jump to
0010H if they are not equal.

000E 80 08 SJMP 0018H Jump to location 0018H

0010 EB MOV A,R3 Copy the content of register


R3 to A
0011 05 F0 INC B Increment the value of B

0013 BA 10 F0 CJNE R2,#10H,0006H CompareR2 with immediate


data 10H and jump to 0006H if
they are not equal.

0016 74 00 MOV A,#00H If root is not found then make


accumulator zero.

0018 80 FE SJMP 0018H Jump to location 0018H

K.Uma Submission Date: 2


(Prof. Incharge)
15TH SEPT 2010
BHILAI INSTITUTE OF TECHNOLOGY, DURG (C.G.)
(SETH BALKRISHAN MEMORIAL)

BHILAI HOUSE, G.E. ROAD, DURG (C.G.)-491001


Department of Electronics & Telecommunication
Engineering
B.E 7th Sem

Sub Code & Name :328713(28)Microcontroller & Embedded Systems Lab.


Roll No: 111

END END of the program.

Result:

INPUT OUTPUT
MEMORY DATA LOCATION DATA
LOCATION ACCUMULATOR 0BH
30H 79H (A)

NOTE: Above assembly language coding is suitable for finding square roots of perfect
squares upto 255 i.e. FFH.

K.Uma Submission Date: 3


(Prof. Incharge)
15TH SEPT 2010

You might also like