User Tools

Site Tools


base:kernal_floating_point_mathematics

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
base:kernal_floating_point_mathematics [2017-10-22 15:22] – [7.3 Integer to FP] shrydarbase:kernal_floating_point_mathematics [2019-10-14 09:45] – [Zero Page Locations] silverdr
Line 30: Line 30:
 **$69** holds the exponent\\ **$69** holds the exponent\\
 **$6a-$6d** holds the mantissa\\ **$6a-$6d** holds the mantissa\\
-**$63** holds the sign in bit 7\\+**$6e** holds the sign in bit 7\\
  
  
Line 41: Line 41:
 **$68** is used during normalisation, and also when converting a FP number to an integer (two similar operations). **$68** is used during normalisation, and also when converting a FP number to an integer (two similar operations).
  
-**$6f** holds the sign result of arithmetic operations. This byte is set when FAC2 is loaded, not when FAC1 is loaded. FAC2 should be loaded after FAC1 before addition, or multiplication. Division does its own compare, so copying FAC1 into FAC2 and then loading FAC1 does not produce erroneous signs. Subtraction negates FAC1 and then comparessetting this byte.+**$6f** holds the sign result of arithmetic operations. This byte is set when FAC2 is loaded, not when FAC1 is loaded. FAC2 should be loaded after FAC1 before addition, or multiplication. Subtraction negates FAC1 and then compares, setting this byte. Unless called at FDIVT ($bb12), division does its own compare, so copying FAC1 into FAC2 and then loading FAC1 does not produce erroneous signs. When FDIVT is usedvalue of this byte may contain incorrect sign, leading to errors in later operations. Please note that this address is used also by other routines – as string pointer for example – and therefore should be treated as volatile, even if no FP routines are invoked after its value is established.
  
 **$70** is the low order rounding byte for FAC1, essentially an extension of the mantissa. It is cleared whenever a variable is loaded into FAC1. Storing 0 here after obtaining a result can speed execution (at the cost of accuracy) by avoiding the rounding routines. **$70** is the low order rounding byte for FAC1, essentially an extension of the mantissa. It is cleared whenever a variable is loaded into FAC1. Storing 0 here after obtaining a result can speed execution (at the cost of accuracy) by avoiding the rounding routines.
Line 68: Line 68:
  
 ---- ----
- 
 ====== The Floating Point Routines ====== ====== The Floating Point Routines ======
  
Line 432: Line 431:
   
  lda value ;get guess based on argument  lda value ;get guess based on argument
 +        clc
  ror  ror
  bcs sqrtadd  bcs sqrtadd
  ldx #$80  ldx #$80
- sta result+1+ stx result+1
 sqrtadd adc #$40 sqrtadd adc #$40
  sta result  sta result
base/kernal_floating_point_mathematics.txt · Last modified: 2020-12-06 20:48 by pararaum