[Assembly Help] Hex to BCD conversion

proton

Veteran X
So I have this Assembly project to do, and in it I have to convert a hexadecimal number to the BCD representation. And I honestly have no idea how to do it. So maybe if anyone could help me out and explain the algorithm I need to use, I can figure it out.

Thanks.
 
I know how to do it outside of Assembly but I don't know how to do it with all the register transfer bullshit and limitations of Assembly.

in case yall were wondering.
 
mov ax, 0
mov bx, 0
int 16

gogogo

btw that assignment sounds like a pain in the ass, though not really difficult

write a C program that does it, then compile it and look at the assembly listing :p
 
Last edited:
mov ax, 0
mov bx, 0
int 16

gogogo

btw that assignment sounds like a pain in the ass, though not really difficult

write a C program that does it, then compile it and look at the assembly listing :p


it isn't hard, i have the rest of the project done already...and like i understand the concept here and everything, i just don't know like "shift left twice, then add 2, then shift left again, then blah blah blah" that bullshit, so i can put it into code. just need like the general idea to convert it and i can put it into code.

ps assembly is gay but i like it more than c++
 
hex to bcd is no different than hex to binary, or binary to bcd

i.e.

the first place is 16^0, second place is 16^1, third place is 16^2, just like in binary first place is 2^0, second is, 2^1, etc...

if you can't understand that then switch majors
 
it isn't hard, i have the rest of the project done already...and like i understand the concept here and everything, i just don't know like "shift left twice, then add 2, then shift left again, then blah blah blah" that bullshit, so i can put it into code. just need like the general idea to convert it and i can put it into code.

ps assembly is gay but i like it more than c++

Google is your friend:

http://www.engr.udayton.edu/faculty/jloomis/ece314/notes/devices/binary_to_BCD/bin_to_BCD.html
 
hex to bcd is no different than hex to binary, or binary to bcd

i.e.

the first place is 16^0, second place is 16^1, third place is 16^2, just like in binary first place is 2^0, second is, 2^1, etc...

if you can't understand that then switch majors

read the thread you stupid fuck



i found that site, it isn't helping me. you can't really check the 10s place or 100s place like that with this assembly, it doesn't have a way to do that.
 
read the thread you stupid fuck




i found that site, it isn't helping me. you can't really check the 10s place or 100s place like that with this assembly, it doesn't have a way to do that.

Use an AND with 0x00000F00 or whatever to isolate whatever field you want, shift it over and compare.
 
Back
Top