You have two options:
1) Store the hex digits and display them in reverse later.
2) Work from the most significant digit first.
Option2 isn't as bad as it sounds, not realy.
1) Set up a boolean called "leadingZero" and set it to true
2) Set up a shift count, set it to 28 (for 32 bit numbers, 60 for 64 bit)
3) Loop though all digits.
3.1) Shift the input by shift count bits, using the >> operator and mask it to a digit:
digit = (input >> shiftCount) & 0xF;
3.2) If the digit not zero or leadignZero is false print the digit. Set leading Zero to false
3.3) Reduce shiftCount by 4 and loop back to 3.1