FAST binary to hex string conversion 
Author Message
 FAST binary to hex string conversion

Looking for a *very fast* BASM routine to convert an integer
to a hexadecimal string.   Searched web but came up dry.

Any pointers appreciated.



Wed, 18 Jun 1902 08:00:00 GMT  
 FAST binary to hex string conversion

Quote:

> Looking for a *very fast* BASM routine to convert an integer
> to a hexadecimal string.   Searched web but came up dry.

No idea if it's fast enough, but try this:

const
  HexChars : array[0..$F] of char = '0123456789ABCDEF';

function Hex(i: integer): string; assembler;
asm

  lea   bx, HexChars
  mov   byte ptr es:[di], 4
  inc   di
  mov   cl, 12

  mov   ax, dx
  shr   ax, cl
  and   al, 0Fh
  xlat
  mov   es:[di], al
  inc   di
  sub   cl, 4

end;



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Binary to Hex? Hex to Binary? -HELP!!

2. Hex to ASCII conversion ?

3. Integer to HEX conversion ???

4. ASCII to HEX Conversion help please!!!

5. Help with ASCII to HEX conversion please

6. Decimal to Hex Conversion

7. Decimal to Hex Conversion

8. Bin to Hex conversion

9. Binary to Hex

10. Convert hex to binary

11. Convert a String to HEX

12. Convert String to Hex

 

 
Powered by phpBB® Forum Software