![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 9
![]() |
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.
__________________
... |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2005
Posts: 89
Rep Power: 9
![]() |
are you sure you aren't asking the question backwards? what you're asking for is easy.
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 9
![]() |
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. |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 89
Rep Power: 9
![]() |
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. |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 9
![]() |
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.
__________________
... |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|