home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 612b.lha / IAS_Library / IAS.DOC.pp / IAS.DOC
Text File  |  1992-03-02  |  5KB  |  173 lines

  1.   IAS Library - A fixed Point Maths Library
  2.  
  3.    By  C Eales 1991
  4.  
  5. The IAS library is a library that has functions for handling fixed point 32 bit    
  6. mathematics, it uses the following format for its numbers :- 
  7.  
  8.  x   xxxxxxxxxxxxxxx .  xxxxxxxxxxxxxxxx
  9.  
  10.  31      30-16            15-0
  11.  
  12. Bit 31 is the sign bit (0 = + , 1 = -)
  13. Bits 30-16 Hold the absolute integer value of the number 0-32767.
  14. Bits 15-0  Hold the fractional part of the number (divide value by 65536 to 
  15. find the value of the fraction.
  16.  
  17. But for most purposes this is Un-needed as the library contains nearly all
  18. the functions you need. The library comes in an assembler only form, as 
  19. I don't know how C stubs are created (could someone write one?) But the
  20. routines are quite straight forward so a C front end should be easy to write.
  21. The library also contains a few integer routines, to make programming with 
  22. the library easier.  At the moment there isn't a comparison routine, but
  23. cmp.l d0,d1 will work for absolute values and then if they are signed, it
  24. just involves a little extra work, but I havent had time (or need) to put
  25. it in yet! Also there is a slight problem with the ASCII routines, in that
  26. it uses an internal workspace, so if your task is calling one and it gets
  27. stopped half way through by another task, then that task calls the routine
  28. then the result will get garbled, so it is safest to call FORBID and PERMIT
  29. around any calls to the ASCII routines, I could put it in the routines but I
  30. don't like the idea of calling FORBID in a library, incase a DEADLOCK occurs
  31. (so it's your problem not mine now).
  32.  
  33. This Libray,include file,docs are freeware, so please distribute freely.
  34. I can be reached at the following address if you want to ask about something:
  35.  
  36. Craig Eales
  37. 6 Orchard Park
  38. Grimoldby
  39. LOUTH
  40. Lincs
  41. LN11 8SW
  42.  
  43. ENGLAND
  44.  
  45.  
  46. Or by email at CSTDXGD@WARWICK.AC.UK
  47.  
  48.  
  49. The Functions
  50.  
  51.  
  52. INTmulu  -  Multiply 2 unsigned 32 bit integers
  53.  
  54. inputs d0 - 32 bit integer
  55.        d1 - 32 bit integer
  56.  
  57. result d2 - 32 bit unsigned product of d0,d1
  58.  
  59. It just multiplies the two arguments together in 32 bit form and returns 
  60. the value in d2.
  61.  
  62.  
  63. INTdivu  -  Divide 2 unsigned 32 bit integers
  64.  
  65. inputs d0 - 32 bit integer
  66.        d1 - 32 bit integer
  67.  
  68. result d2 - unsigned 32 bit result of d0/d1
  69.  
  70. This is a full 32 bit unsigned divide of integers. It is based on the one
  71. in the ARP library.
  72.  
  73.  
  74. IASdivs  -  Multiply 2 IAS numbers
  75.  
  76. inputs d0 - IAS format number
  77.        d1 - IAS format number
  78.  
  79. result d2 - IAS format number which is d0/d1
  80.  
  81. This caries out a full IAS signed division of d0 by d1 and then puts the
  82. result into d2.
  83.  
  84.  
  85. IASabs   -  Find Absolute Value of an IAS number
  86.  
  87. inputs d0 - an IAS format number
  88.  
  89. result d0 - an IAS format number = abs(d0)
  90.  
  91. This just adjusts the IAS number in d0 to its mod value.
  92.  
  93.  
  94. IAScif   -  Convert a signed integer to IAS form
  95.  
  96. inputs d0 - 16 Bit signed Integer (sign on the 32 bits)
  97.  
  98. result d0 - The IAS representation of d0
  99.  
  100. This takes the argument integer in d0 and converts it into an IAS format
  101. number. NOTE It only evaluates the final 16 bits but checks its sign on the
  102. full 32 bits, so $0000FFFF will be converted to  32767.0 in IAS.
  103.  
  104.  
  105. IAScfi   -  Convert IAS form number to a signed integer
  106.  
  107. inputs d0 - an IAS format number
  108.  
  109. result d0 - A signed 32 bit integer equal to trunc(d0)
  110.  
  111. This converts the passed IAS number into its signed intteger form (all
  112. fractions are dropped).
  113.  
  114.  
  115. IASsub   -  Subtract two IAS numbers
  116.  
  117. inputs d0 - IAS format number
  118.        d1 - IAS fromat number
  119.  
  120. result d2 - IAS format number equal to d0-d1
  121.  
  122. This just subracts the second argument from the first and stores it in d2.
  123.  
  124.  
  125. IASadd   -  Add two IAS numbers
  126.  
  127. inputs d0 - IAS format number
  128.        d1 - IAS format number
  129.  
  130. result d2 - IAS format number which equals d0+d1
  131.  
  132. This adds together the arguments then stores the result in d2.
  133.  
  134.  
  135. IASmuls  -  Multiply two IAS numbers
  136.  
  137. inputs d0 - IAS format number
  138.        d1 - IAS format number
  139.  
  140. result d2 - IAS format number which equals d0*d1
  141.  
  142. This multiplies the two arguments together and returns in d2 the result.
  143.  
  144.  
  145. IASdivi  -  Divide an IAS number by an integer
  146.  
  147. inputs d0 - IAS format number
  148.        d1 - 32 bit signed integer
  149.  
  150. result d2 - IAS format number which equals d0/d1
  151.  
  152. This divides an IAS number by an integer and returns the result in d2, this
  153. is quicker than dividing by an IAS number.
  154.  
  155.  
  156. IAScfa   -  Convert an IAS number to an ASCII string
  157.  
  158. inputs d0 - IAS format number
  159.        a0 - a pointer to a 12 byte buffer
  160.  
  161. This converts an IAS number into an ascii  null terminated string starting
  162. at a0.
  163.  
  164.  
  165. IAScia   -  Convert 32 bit signed integer to an ASCII string
  166.  
  167. inputs d0 - a 32 bit signed integer
  168.        a0 - a pointer to a 12 byte buffer
  169.  
  170. This converts a 32 bit signed integer into a null terminated string starting 
  171. at a0.
  172.  
  173.