base:kernal_floating_point_mathematics

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

Both sides previous revision Previous revision | |||

base:kernal_floating_point_mathematics [2019-10-14 10:07] silverdr [2.4 Division] |
base:kernal_floating_point_mathematics [2020-04-22 06:06] (current) robin_8bst [7.3 Integer to FP] |
||
---|---|---|---|

Line 239: | Line 239: | ||

The first routine is the actual code. The other entries simply set up $62/$63 for you. This routine wrecks FAC2, so if it is needed, it should be loaded after the conversion. It also uselessly (from our ML standpoint) sets the data type flag at $0d. Skipping these routines and jumping straight to the normalization routine at **$b8d2** gives greater control, i.e. 24-bit and 32-bit integer inputs are possible, as are signed 8-bit inputs. For example, to convert a 24-bit number, load FAC1 with the number from the most-significant byte to the least. Store zero in the last mantissa byte, and also in the sign and rounding bytes ($66 and $70). Then set the exponent to 24 (24 + $80 = $98). Jump to $b8d2 with the carry indicating whether the result should be positive (set) or negative (clear). | The first routine is the actual code. The other entries simply set up $62/$63 for you. This routine wrecks FAC2, so if it is needed, it should be loaded after the conversion. It also uselessly (from our ML standpoint) sets the data type flag at $0d. Skipping these routines and jumping straight to the normalization routine at **$b8d2** gives greater control, i.e. 24-bit and 32-bit integer inputs are possible, as are signed 8-bit inputs. For example, to convert a 24-bit number, load FAC1 with the number from the most-significant byte to the least. Store zero in the last mantissa byte, and also in the sign and rounding bytes ($66 and $70). Then set the exponent to 24 (24 + $80 = $98). Jump to $b8d2 with the carry indicating whether the result should be positive (set) or negative (clear). | ||

- | The above process is basically what the KERNAL authors did to implement the 24 bit TI variable in BASIC (though they zero the high byte instead of the low, and hence use a mantissa of $a0). | + | The above process is basically what the KERNAL authors did to implement the 24 bit TI variable in BASIC (though they zero the high byte instead of the low, and hence use an exponent of $a0). |

You can take advantage of their work with the following pair of calls to convert a 24 bit unsigned integer held in YXA: | You can take advantage of their work with the following pair of calls to convert a 24 bit unsigned integer held in YXA: |

base/kernal_floating_point_mathematics.txt ยท Last modified: 2020-04-22 06:06 by robin_8bst