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

Thank You,
Sharath
Sat Jun 18 2011, 04:42 AM
@ sharath411
ru see this
also this one

Attachment
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

Thanks

[ 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..

Wed Jun 22 2011, 11:20 PM

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...

Sharath
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 ]

Information

Conversation

Wed Nov 08 2017, 01:35 PM
Anirudh jain
I want to burn code in atmel 89s51 24pc 0329 but cannot get the connection with the burner. Can somebody provide me with the circuit diagram for connecting controller to burner. I'm using usb burner
Thu Nov 02 2017, 11:44 AM
karpal
write a program to exchange the content of b register with external RAM address 02CFH help me
Wed Nov 01 2017, 05:47 PM
sanae
i am using the DHT11 but i'm getting some errors in the simulate the programe in proteus 8 professional,: 1)cannot find model file 'DHTXX.MDF'.2)simulation failed due to netlist linker error(s).
Fri Sep 29 2017, 02:45 AM
Maaz
Wed Sep 20 2017, 12:36 AM
Ted
In a missing pulse detector using a 555 timer connected as a monostable vibrator with a PNP transistor,how does the positve input pulse turn on the PNP transistor?
Sun Sep 03 2017, 02:29 PM
martymarty
How do I connect an <NOKIA 1100 LCD > to an atmega328P ?
Sun Aug 20 2017, 10:23 AM
i am intending to interface sd card with STM32F4 and want to write a file in sd card using SPI protocol but using HAL only. Can anyone help me PLEASE!!!!
Sun Aug 20 2017, 10:22 AM
hello
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

Recent

PANDIKOTESWARARAO
Mon Nov 20 2017, 07:40 PM
Hemantika
Sun Nov 19 2017, 07:34 PM
Wed Nov 15 2017, 10:46 AM
Ansh12
Sat Nov 11 2017, 03:43 AM
AngelGT93
Fri Nov 10 2017, 06:53 AM
JardCrocker
Wed Nov 08 2017, 05:27 PM
vivitern
Tue Nov 07 2017, 09:08 AM
catrons
Sat Nov 04 2017, 10:46 PM

Online

Guests: 51, Members: 0 ...

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

Members: 37918
Forum Activity
Posted By ExperimenterUK
Mon Nov 20 2017, 10:18 PM
Here is a version of the tutorial that reads a key...
Posted By Ansh12
Mon Nov 20 2017, 02:15 AM
As a starting point, can you tell us how much of t...
Posted By ExperimenterUK
Sun Nov 19 2017, 08:35 PM
As a starting point, can you tell us how much of t...
Posted By Ansh12
Fri Nov 17 2017, 04:07 AM
I am looking keypad interfacing program. I was rea...
Posted By JardCrocker
Wed Nov 08 2017, 05:29 PM
Hi...i am a new user here. I was also facing the s...
Posted By ExperimenterUK
Tue Nov 07 2017, 07:13 PM
> It employs a fairly advanced technique to detect...
Posted By vivitern
Tue Nov 07 2017, 09:33 AM
I own a used Clavia ddrum4 SE drum module. It empl...
Posted By bvdb
Wed Oct 18 2017, 01:50 AM
I purchased the RKitL51 8051 C compiler from Raiso...
Posted By ExperimenterUK
Mon Oct 16 2017, 11:44 PM
That looks complicated.Is 8051_BLK a standard 80...
Posted By ExperimenterUK
Sun Oct 15 2017, 07:29 PM
According to this, gmail should support POP3.https...