Showing posts with label Binary to decimal conversion using 8051. Show all posts

Assembly language Program for Binary to decimal conversion



org 00h
rs equ p1.0
rw equ p1.1
en equ p1.2
lcd equ p0
MOV LCD,#38H
ACALL CMD
ACALL DELAY
MOV LCD,#06H
ACALL CMD
ACALL DELAY
MOV LCD,#01H
ACALL CMD
ACALL DELAY
MOV LCD,#0EH
ACALL CMD
ACALL DELAY
MOV LCD,#80H
ACALL CMD
ACALL DELAY
CLR A
MOV P2,#0FFH

MOV R0,#04
H2: ACALL KEYBOARD
DJNZ R0,H2
MOV A,R3
MOV B,#08
MUL AB
MOV R3,A

MOV A,R4
MOV B,#04
MUL AB
MOV R4,A

MOV A,R5
MOV B,#02
MUL AB
MOV R5,A

MOV A,R6
MOV B,#01
MUL AB
MOV R6,A

CLR A

ADD A,R3
ADD A,R4
ADD A,R5
ADD A,R6
MOV LCD,#'='
ACALL DISP
ACALL DELAY

MOV B,#10
DIV AB
MOV DPTR,#MSG
MOVC A,@A+DPTR
MOV LCD,A
ACALL DISP
ACALL DELAY
CLR A
MOV A,B
MOV DPTR,#MSG
MOVC A,@A+DPTR
MOV LCD,A
ACALL DISP
ACALL DELAY
ALT: SJMP ALT






KEYBOARD: MOV A,P2
CJNE A,#0FEH,S1
MOV A,#00
CJNE R0,#04,L1
MOV R3,A
L1: CJNE R0,#03,L2
MOV R4,A
L2: CJNE R0,#02,L3
MOV R5,A
L3: CJNE R0,#01,L4
MOV R6,A
L4: SJMP RAM

S1: CJNE A,#0FDH,KEYBOARD
MOV A,#01
CJNE R0,#04,M1
MOV R3,A
M1: CJNE R0,#03,M2
MOV R4,A
M2: CJNE R0,#02,M3
MOV R5,A
M3: CJNE R0,#01,RAM
MOV R6,A

RAM: MOV DPTR,#MSG
MOVC A,@A+DPTR
MOV LCD,A
ACALL DISP
ACALL DELAY
RET

CMD: CLR RS
     CLR RW
                 SETB EN
                 ACALL DELAY
                 CLR EN
                 RET

DISP: SETB RS
      CLR RW
                  SETB EN
                  ACALL DELAY
                  CLR EN
                  RET

DELAY: MOV R1,#0F0H
HERE2: MOV R2,#0FFH
HERE:  DJNZ R2,HERE
       DJNZ R1,HERE2
                   RET

MSG: DB '0','1','2','3','4','5','6','7','8','9'
END


If you have any problem then comment!!!!!!!!!!!!!!!!!!!!!!!!!

Binary to decimal conversion using 8051

                               


                               

This is the circuit diagram of binary to decimal conversion using 8051 microcontroller. Result will be displayed on LCD. We can enter binary number of 4 digit to get the result in decimal. I have connected two switches with the pin p2.0 and p2.1. 

You are required to know about LCD and keypad interfacing. When we press the first switch that is connected to p2.0 then 0 will be displayed on LCD and when we press the switch connected to P2.1 then 1 will be displayed on LCD. 

We just have to enter the 4 binary digit, then result will be automatically displayed on LCD.

CLICK HERE TO SEE THE ASSEMBLY LANGUAGE PROGRAM

- Copyright © Microcontroller Projects -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -