yujaiyu
yujaiyu

Reputation: 9013

Convert decimal to hex in assembly

Can someone explain to me decimal to hex conversion algorithm in assembly?I have a decimal value in a variable and I should print it as a hex value.Print should look like this: 34AC6 .

Upvotes: 1

Views: 4300

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 727067

Assuming that this is a homework, here's a couple of hints:

  • The value in the variable is not in decimal, hex, or any other system: it is in whatever system that your hardware supports (most likely, it is binary).
  • To convert a value to hex, you need to separate out 4-bit chunks by shifting right and masking with 0x0F, and indexing into an array of hexadecimal digits.

Upvotes: 2

Related Questions