IAS Library - A fixed Point Maths Library By C Eales 1991 The IAS library is a library that has functions for handling fixed point 32 bit mathematics, it uses the following format for its numbers :- x xxxxxxxxxxxxxxx . xxxxxxxxxxxxxxxx 31 30-16 15-0 Bit 31 is the sign bit (0 = + , 1 = -) Bits 30-16 Hold the absolute integer value of the number 0-32767. Bits 15-0 Hold the fractional part of the number (divide value by 65536 to find the value of the fraction. But for most purposes this is Un-needed as the library contains nearly all the functions you need. The library comes in an assembler only form, as I don't know how C stubs are created (could someone write one?) But the routines are quite straight forward so a C front end should be easy to write. The library also contains a few integer routines, to make programming with the library easier. At the moment there isn't a comparison routine, but cmp.l d0,d1 will work for absolute values and then if they are signed, it just involves a little extra work, but I havent had time (or need) to put it in yet! Also there is a slight problem with the ASCII routines, in that it uses an internal workspace, so if your task is calling one and it gets stopped half way through by another task, then that task calls the routine then the result will get garbled, so it is safest to call FORBID and PERMIT around any calls to the ASCII routines, I could put it in the routines but I don't like the idea of calling FORBID in a library, incase a DEADLOCK occurs (so it's your problem not mine now). This Libray,include file,docs are freeware, so please distribute freely. I can be reached at the following address if you want to ask about something: Craig Eales 6 Orchard Park Grimoldby LOUTH Lincs LN11 8SW ENGLAND Or by email at CSTDXGD@WARWICK.AC.UK The Functions INTmulu - Multiply 2 unsigned 32 bit integers inputs d0 - 32 bit integer d1 - 32 bit integer result d2 - 32 bit unsigned product of d0,d1 It just multiplies the two arguments together in 32 bit form and returns the value in d2. INTdivu - Divide 2 unsigned 32 bit integers inputs d0 - 32 bit integer d1 - 32 bit integer result d2 - unsigned 32 bit result of d0/d1 This is a full 32 bit unsigned divide of integers. It is based on the one in the ARP library. IASdivs - Multiply 2 IAS numbers inputs d0 - IAS format number d1 - IAS format number result d2 - IAS format number which is d0/d1 This caries out a full IAS signed division of d0 by d1 and then puts the result into d2. IASabs - Find Absolute Value of an IAS number inputs d0 - an IAS format number result d0 - an IAS format number = abs(d0) This just adjusts the IAS number in d0 to its mod value. IAScif - Convert a signed integer to IAS form inputs d0 - 16 Bit signed Integer (sign on the 32 bits) result d0 - The IAS representation of d0 This takes the argument integer in d0 and converts it into an IAS format number. NOTE It only evaluates the final 16 bits but checks its sign on the full 32 bits, so $0000FFFF will be converted to 32767.0 in IAS. IAScfi - Convert IAS form number to a signed integer inputs d0 - an IAS format number result d0 - A signed 32 bit integer equal to trunc(d0) This converts the passed IAS number into its signed intteger form (all fractions are dropped). IASsub - Subtract two IAS numbers inputs d0 - IAS format number d1 - IAS fromat number result d2 - IAS format number equal to d0-d1 This just subracts the second argument from the first and stores it in d2. IASadd - Add two IAS numbers inputs d0 - IAS format number d1 - IAS format number result d2 - IAS format number which equals d0+d1 This adds together the arguments then stores the result in d2. IASmuls - Multiply two IAS numbers inputs d0 - IAS format number d1 - IAS format number result d2 - IAS format number which equals d0*d1 This multiplies the two arguments together and returns in d2 the result. IASdivi - Divide an IAS number by an integer inputs d0 - IAS format number d1 - 32 bit signed integer result d2 - IAS format number which equals d0/d1 This divides an IAS number by an integer and returns the result in d2, this is quicker than dividing by an IAS number. IAScfa - Convert an IAS number to an ASCII string inputs d0 - IAS format number a0 - a pointer to a 12 byte buffer This converts an IAS number into an ascii null terminated string starting at a0. IAScia - Convert 32 bit signed integer to an ASCII string inputs d0 - a 32 bit signed integer a0 - a pointer to a 12 byte buffer This converts a 32 bit signed integer into a null terminated string starting at a0.