Discussion in "8051 Discussion Forum" started by    sharath411    Jun 18, 2011.
Sat Jun 18 2011, 04:15 AM
Hi friends

how to convert a 24 bit bcd to binary for 8051 in assembly. Ex: 100000 to 186AD

Please help me

Thank You,
Sat Jun 18 2011, 04:42 AM
Sat Jun 18 2011, 05:03 AM

The link you provided is for binary to bcd, but i want bcd to binary

If you know please tell me how to do that


[ Edited Sat Jun 18 2011, 05:22 AM ]
Mon Jun 20 2011, 07:39 PM
its really simple...
lets say you have 0x29 as BCD so to convert it to binary.. just do this..

//this is a pseudo code... kind of..
binary = (x & 0x0F) + (((x>
4) &0x0F) * 10);
//here x is BCD number...
Wed Jun 22 2011, 09:28 AM
Thanks Ajay,

But i want to convert 6 digit decimal to binary, what you provided is only for 2 digit..

Please help me....
Wed Jun 22 2011, 11:20 PM
Help you by doing it for you, or help you figure out how to do it? There is a difference...

Ajay has demonstrated the technique. Binary Coded Decimal numbers are coded such that each nibble (which means 4 bits) has a value in it that represents the ones, tens, hundreds, thousands, etc... place in a decimal number.

He has shown how to shift the second value (the "tens" place) and multiply it by 10.
He has shown how to isolate the first value ( the "units" place) and add it to the shifted value...

Can you see how you might get the thousands place? That's right: you shift it to the right 8 bits...
And what about the 10-thousands value? Right again: you shift it to the right 12 bits...
and so on, and so on...
once you have each value isolated, you multiply it by the corresponding value it represents, like in the above example.

Then you add them all together, and tah dah! You have your value...

It's really quite easy, but you must understand the concept BEFORE you attempt to code it yourself...
Thu Jun 23 2011, 06:52 AM
Thank You DAVE,

Could you explain me in Assembly language because am getting very much confusion there...

Thu Jun 23 2011, 12:28 PM
@ sharath411
logic is same as in asm as well as in c
Thu Jun 23 2011, 03:30 PM
Yes, the logic is the same. Also, if it's the syntax of assembly that you are having a problem with, you can always write it in C, and then compile it, and have a look at the assembly file that is generated by the compiler to see exactly how it's done in assembly... just a suggestion.
Thu Jun 23 2011, 08:00 PM
Doing this in 8051 assembly is actually quite complicated and tedious.
Are you sure you have to do it all ,what is it for ?

Basically you need to split the 3 bcd bytes into 6 single bytes containing 0-9
Create a 3 byte final total.
Multiply the 6 bytes by an increasing power of ten 1,10,100,1000,10000,100000
Add the result of each multiplication to the final total.

The heart of your routine will be a subroutine that can multiply an 8 bit value
by a 16 or 24 bit value.

Obviously you don't actually multiply by 1, and by multiplying by ten first you can
get away with 8 bit by 16 bit multiplication.

[ Edited Fri Jun 24 2011, 08:34 PM ]

Get Social


Powered by e107 Forum System


Fri Aug 18 2017, 11:37 AM
hi @ angel patel i will attach a file i hope it will be helpfull for you
Mon Aug 14 2017, 09:57 PM
@ angel patel... just log in and post your problem
Mon Aug 14 2017, 01:45 PM
angel patel
hey any one help to make the led scrolling display
Sat Jul 29 2017, 07:09 AM
I see the code for step motor h l 298 to rotate 45 degree, but all delay time, if I want to input sensor to h the pulses to stepmotor
Thu Jul 27 2017, 12:05 PM
okay fine
Wed Jul 26 2017, 07:51 PM
Please post questions in the forum, the chat box is for chat
Wed Jul 26 2017, 11:27 AM
i need code if any one have aduc706 interfacing lcd 16*2
Wed Jul 26 2017, 11:26 AM
pl help me how to write code of interfacing ADuc7026 controlleo lcd pl any one help me hoe to initializend configure the direction
Wed Jul 26 2017, 06:04 AM
can you explain what is timer and how to use their modes ...
Wed Jul 26 2017, 06:03 AM
ExperimenterUk thank you for your quick reply okay



Sat Aug 19 2017, 08:40 AM
Thu Aug 17 2017, 02:02 PM
Wed Aug 16 2017, 04:47 AM
Sun Aug 13 2017, 05:49 PM
Fri Aug 11 2017, 08:10 AM
Sat Aug 05 2017, 05:17 PM
Thu Aug 03 2017, 08:32 AM
Tue Aug 01 2017, 12:41 PM


Guests: 61, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37879
Newest member: kira113
Forum Activity
kira113 Avatar
Posted By kira113
Sat Aug 19 2017, 08:52 AM
hello everyone i write a simple program using c la...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Aug 19 2017, 02:47 AM
else x+=0x46; //print as ascill 0x41 to 0x46 A-F ...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 02:58 PM
Dear Sir, I have a another program in which I am a...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:45 AM
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:24 AM
Dear Sir , I am not able to increased value by pre...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:19 AM
Dear Sir, as per your attachment I w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Aug 17 2017, 10:54 PM
Try this. Attachment ...
rawat742 Avatar
Posted By rawat742
Thu Aug 17 2017, 08:24 PM
Dear Sir , Please help me for stor...
sathishksk71 Avatar
Posted By sathishksk71
Wed Aug 16 2017, 04:53 AM
Hi.. Iam refreshing c language using this useful r...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Aug 14 2017, 10:19 PM
The original 8051 is a primitive device.Over the ...