top decor
ROM subroutines Convert INT64 to DOUBLE

This subroutine has two main branches:
  1. when intreger argument has more than 53 bits (including the most significant one that will be hidden!), we must shift the value right to get normalized mantissa;
  2. othewise we'll shift argument in opposite direction until 1 will appear in the 52th - the most significant in mantissa - bit (bits 0-51 will form normalized mantissa at this moment).
In both cases the process ends when bit number 52 will be 1, and bits 53-63 are 0 - the character feature of normalized mantissa. 52th bit is not stored - so called hidden bit.

When INT64 number is equal to 25210 = 23416, its mantissa will be normalized promptly. Hexadecimal exponent in this case can be calculated as 34 + 3FF = 433 (this constant is used in the second insruction of the subroutine).


addr code mnemonic action comments
EE0...1A44271 0017BZ $71, 0017branch to 200 if $71 = 0exit if argument is 0
1A8E072 4330SETH $72, 4330$72 <== 4330..00this value has exponent when INT64 already forms normal mantissa (53 bits)
1AC3173 7100CMPI $73, $71, 00compare $71 with 0 and set $73is argument negative?
1B04873 0003BNN $73, 0003branch to 1BC if $73 >= 0bypass if sign is plus
1B4C571 7100NORI $71, $71, 00$71 <== NOT $71convert to positive value
1B8E771 0001INCL $71, 0001$71 <== $71 + 1
1BCE074 FFE0SETH $74, FFE0$74 <== FFE0..00constant to test if INT64 has more bits than mantissa
1C0E075 0010SETH $75, 0010$75 <== 0010..00set the less signisicant exponent's bit
1C4C876 7471AND $76, $74, $71$76 <== $74 AND $71reset 53 lower bits of argument
1C84276 0004BZ $76, 0004branch to 01D8 if $76 = 0further if higher bits are empty
1CC3D71 7101SRI $71, $71, 01right shift $71INT64 must be shifted right to form normal mantissa
1D02072 7275ADD $72, $72, $75$72 <== $72 + $75INC exponent
1D4F1FF FFFCJMPB FFFFFCbranch to 01C4repeat the cycle
1D8E074 FFF0SETH $74, FFF0$74 <== FFF0..00constant to reset mantissa except its 52th bit
1DCC876 7471AND $76, $74, $71$76 <== $74 AND $71clear mantissa to test the most significant bit
1E04A76 0004BNZ $76, 0004branch to 1F0finish cycle when it is 1
1E43971 7101SLI $71, $71, 01left shift $71INT64 must be shifted left to form normal mantissa
1E82472 7275SUB $72, $72, $75$72 <== $72 - $75DEC exponent
1ECF1FF FFFCJMPB FFFFFCbranch to 1DCrepeat the cycle
1F02471 7175SUB $71, $71, $75$71 <== $71 - $75clear the most sidnificant (hidden) bit in mantissa
1F4C071 7172OR $71, $71, $72$71 <== $71 OR $72combine mantissa with exponent
1F84873 0002BNN $73, 0002branch to 200 if $73 >= 0bypass if argument was not negative
1FCE471 8000INCH $71, 8000$71 <== $71 + 80..00set negative sign
200 9F6F 6F00GOI $6F, $6F, 0 return using $6F(finish subroutine)

back previous page next page forward


Related topics:

E-MMI software
 

  (C) 2009, Evgeny Eremin. rEd-MMI project documentation