Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 24th, 2005, 6:14 PM   #1
Xero
Hobbyist Programmer
 
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 10 Xero is on a distinguished road
How to convert BCD to Hex

How do you convert BCD to Hex? anyone got an example code of this? I know how some basic algorithms for it, but the implementation seems difficult.
__________________
...
Xero is offline   Reply With Quote
Old Feb 24th, 2005, 6:42 PM   #2
brkstf
Programmer
 
brkstf's Avatar
 
Join Date: Feb 2005
Posts: 89
Rep Power: 10 brkstf is on a distinguished road
are you sure you aren't asking the question backwards? what you're asking for is easy.
brkstf is offline   Reply With Quote
Old Feb 24th, 2005, 7:00 PM   #3
Xero
Hobbyist Programmer
 
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 10 Xero is on a distinguished road
ummm how? im looking a simple method. I know how to do it, but its too complex

i can already do the reverse, since theres a command for bit adjustment
__________________
...

Last edited by Xero; Feb 24th, 2005 at 7:04 PM.
Xero is offline   Reply With Quote
Old Mar 3rd, 2005, 11:39 AM   #4
brkstf
Programmer
 
brkstf's Avatar
 
Join Date: Feb 2005
Posts: 89
Rep Power: 10 brkstf is on a distinguished road
for a two-digit bcd number HHHHLLLL

all you do is multiply 0000HHHH by dec 10 (bin 1010) and add to 0000LLLL. for two-byte (4 nibble) values, you just multiply by dec100 and dec1000, following the pattern.

i hope that answers your question. my asm sucks and i only speak PIC. this program is probably like 25+ lines of PIC ASM. in x86, it's probably about 4 or 5.
brkstf is offline   Reply With Quote
Old Mar 4th, 2005, 1:26 PM   #5
Xero
Hobbyist Programmer
 
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 10 Xero is on a distinguished road
nah I got it already. That was like a week ago

Thanks. My code was basically what you did brkstf. Multiply the high 4 bits by 10. Wish I knew this earlier. Would have saved me time Thanks though.
__________________
...
Xero is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:13 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC