Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!microsoft!brianw From: brianw@microsoft.UUCP (Brian Willoughby) Newsgroups: comp.sys.apple Subject: Re: Beginner in Assembly Summary: Try Fixed Point math - it's faster Keywords: Assembly, source code, etc. Message-ID: <36@microsoft.UUCP> Date: 14 Jul 89 04:36:17 GMT References: <8907060856.AA01161@crash.cts.com> <6783@sdcsvax.UCSD.Edu> <3425@portia.Stanford.EDU> Reply-To: brianw@microsoft.UUCP (Brian Willoughby) Organization: Microsoft Corp., Redmond WA Lines: 39 In article <3425@portia.Stanford.EDU> kodali@Portia.Stanford.EDU (VAS KODALI) writes: > >..., can anyone tell me how to do >floating point calculations from assembly? I'm trying to calculate >fractions in this one subroutine, and this is a BIG stumbling block. >I got around the required deadline by jumping into BASIC and having it >handle the FP calculations, but I view this as a kludge, while it did >turn out to be an elegant one in the end. > >Chan This may not be the answer you were looking for, but... Try using fixed point math that is tailored to your need for accuracy. I usually use 24 bit numbers, and "pretend" that there is a decimal point after the 16th bit. Then when you need the whole part of the number, you just access the most significant 16 bits. Of course, this means that you'll have to write custom divide routines which take into account your particular fixed point notation, but if you don't like relying in the BASIC routines, then you probably shouldn't use the divide routine in the Monitor area of the Firmware. Now I did say that I usually use 24 bits. At one point, this wasn't enough, because the rounding errors (in my graphics output) were very apparent. So I just increased my notation to 32 bits, 16 whole and 16 fractional part. Again, I had to rewrite my divide routine, but it was a good exercise to be able to understand codeing fast 6502 divide routines anyway. p.s. The multiply routines also need to be tailored to the notation used, but I find multiply routines to be an order of magnitude easier than divide! p.p.s. If speed is a factor, you'll really like fixed point! Brian Willoughby UseNet/UUCP ...!{sun|uw-beaver|uunet}|microsoft!brianw Bitnet microsoft!brianw@Sun.COM brianw@microsoft.UUCP