I have code that looks like:
mov dl, 05
mov dh, 05

I can combine these 2 commands into:
mov dx, 0505H

What I don't understand is why is it necessary for '0505' to be in hex. If I make the command:
mov dx, 0505
it does not work right. Actually, I think I understand why it does not work right in dec. but not why it does work in hex. Can someone explain this. I hope for details on this 1. I'm an idiot. Thank you.

Recommended Answers

All 2 Replies

Hex is base16 (0-F) while Dec is base10 (0-9). If you do a 'mov dh,05' then the value of dx in decimals will not be 5*(10^2)=500 but 5*(16^2)=1280.

Thus, a 'mov dh, 05' and 'mov dl, 05' is in decimal 5*(16^2)+5, a 'mov dx, 0505h' is in decimal 5*(16^2)+5 as well but a mov dx, 0505' is in decimal 5*(10^2)+5.

Hope this makes sence.

Thank you. I think I have it straight in my head now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.