![]() | ![]() | ![]() |
| | |||||||
| 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? |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| :idea: Have a Look-Up Table | |
| |
| | (permalink) |
| POST DELETED BY MODERATOR!
__________________ Top o, the morning te ya. | |
| |
| | (permalink) |
| come again ? U disgusting worm ** MODS please step in ** | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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!" | |
| |
| | (permalink) |
| 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. | |
| |