Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion?

Reply
 
LinkBack Thread Tools Display Modes
Old 8th November 2005, 04:51 PM   (permalink)
Default binary to bcd

I need to convert a 8 bit binary output to 2 bcd numbers for driving 2 seven seg displaysfrom an 8051.If anyone could tell me how to do this as a software solution in the mcs 51 assembler language.
__________________
Top o, the morning te ya.
jimbob jones is offline  
Old 8th November 2005, 05:52 PM   (permalink)
Default

:idea: Have a Look-Up Table
Electrix is offline  
Old 8th November 2005, 05:56 PM   (permalink)
Default binary to bcd

POST DELETED BY MODERATOR!
__________________
Top o, the morning te ya.
jimbob jones is offline  
Old 8th November 2005, 06:01 PM   (permalink)
Default

come again ?


U disgusting worm
** MODS please step in **
Electrix is offline  
Old 9th November 2005, 03:29 PM   (permalink)
Default biary tto bcd

I must apologise for my comment, a friend of mine was messing about and wrote that. I hope no one was offended by those silly remarks. Still is there anyone proficient in mcs 51 assembler language that can help me with the original problem.
__________________
Top o, the morning te ya.
jimbob jones is offline  
Old 9th November 2005, 07:15 PM   (permalink)
Default

Here is how you do it:
Code:
;********************************************************************
; FUNCTION: BIN2BCD8
; PURPOSE:  CONVERTS 8-BIT NUMBER TO TWO BCD DIGITS
; INPUT:    A HAS 8-BIT NUMBER TO BE CONVERTED TO BCD
; OUTPUT:   BCD1 = HIGH NIBBLE
;           BCD0 = LOW NIBBLE
;********************************************************************
BIN2BCD8:
    MOV     R0,A
    ANL     A,#0FH
    ADD     A,#0F6H
    JNC     BB2
    ADD     A,#07H
BB2:ADD     A,#3AH
    XCH     A,R0
    SWAP    A
    ANL     A,#0FH
    ADD     A,#0F6H
    JNC     BB3
    ADD     A,#07H
BB3:ADD     A,#3AH
    MOV     BCD1, A
    MOV     BCD0, R0
    RET
__________________
"There is no way to peace, peace is the way!"
kinjalgp is offline  
Old 9th November 2005, 07:57 PM   (permalink)
Default binary to bcd

Good man. Thanks for the help, i was going to use a binary to bcd converter ,a 74185 but couldnt get one. Much better to do it with software. I am only beginning assembler so i was'nt fully familiar with all the instructions.
__________________
Top o, the morning te ya.
jimbob jones is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 07:17 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker