base:hexadecimal_to_decimal_conversion

This shows you the differences between two versions of the page.

base:hexadecimal_to_decimal_conversion [2015-04-17 04:32] 127.0.0.1 external edit |
base:hexadecimal_to_decimal_conversion [2020-11-14 23:09] (current) mace Added/moved redirections to other routines at the top |
||
---|---|---|---|

Line 1: | Line 1: | ||

====== Hexadecimal to Decimal Conversion ====== | ====== Hexadecimal to Decimal Conversion ====== | ||

Without division or multiplication, | Without division or multiplication, | ||

+ | |||

+ | See also [[More Hexadecimal to Decimal Conversion]]. Andrew Jacobs has written equivalent routines to the ones presented here, eliminating the lookup tables in exchange for a little slower execution speed. | ||

+ | |||

+ | If you need a routine that decodes hex to plain ascii, try [[Another Hexadecimal to Decimal Conversion]]. | ||

< | < | ||

; A = Hex input number (gets put into HTD_IN) | ; A = Hex input number (gets put into HTD_IN) | ||

Line 116: | Line 120: | ||

Note by Karoshier: The above code can be easily made a little faster and shorter by splitting the data table into three separate tables, one for the low digits, one for the mid digits and one for the high digits. This way the index can be initialized to 15 instead of 45 and be decremented by 1 instead of 3, thereby saving 4 cycles per iteration and making the routine shorter by 2 bytes. If you have space constraints and you need an 8 bit version as well, you can also make the 16 bit version work for both 8 or 16 bits by changing the initial value of X according to the needs (namely 3 times 7 instead of 3 times 15) and patching the ROL opcode on the fly to a BIT instruction, | Note by Karoshier: The above code can be easily made a little faster and shorter by splitting the data table into three separate tables, one for the low digits, one for the mid digits and one for the high digits. This way the index can be initialized to 15 instead of 45 and be decremented by 1 instead of 3, thereby saving 4 cycles per iteration and making the routine shorter by 2 bytes. If you have space constraints and you need an 8 bit version as well, you can also make the 16 bit version work for both 8 or 16 bits by changing the initial value of X according to the needs (namely 3 times 7 instead of 3 times 15) and patching the ROL opcode on the fly to a BIT instruction, | ||

- | |||

- | See also [[More Hexadecimal to Decimal Conversion]]. Andrew Jacobs has written equivalent routines to the ones presented here, eliminating the lookup tables in exchange for a little slower execution speed. |

base/hexadecimal_to_decimal_conversion.txt ยท Last modified: 2020-11-14 23:09 by mace