Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!cbmvax!fred From: fred@cbmvax.UUCP (Fred Bowen) Newsgroups: comp.sys.cbm Subject: Re: C Power 128 Float to Int conversion clarified Message-ID: <2717@cbmvax.UUCP> Date: Tue, 10-Nov-87 13:55:06 EST Article-I.D.: cbmvax.2717 Posted: Tue Nov 10 13:55:06 1987 Date-Received: Fri, 13-Nov-87 00:06:31 EST References: <5519@rutgers.rutgers.edu> Organization: Commodore Technology, West Chester, PA Lines: 40 In article <5519@rutgers.rutgers.edu>, prindle@NADC.ARPA writes: > From: prindle@nadc.arpa (Frank Prindle) > > [...] It is the routine to convert floating point to > integers (jump table address $AF00) that does not return it's result in A,Y. > Additionally, *as I said before*, that routine does not work correctly unless > the FAC has had any fractional part removed by INT first. I don't know if > either of these has been changed by the upgrade ROM, but my fix makes it work > on any 128 (in theory!). It is simply not sufficient to fix the A,Y register > problem, you also have to do the INT fix. The routine is called AYINT (C128 jump table $AF00). It returns its result in FACMO (msb: $66 in C128, $64 in C64) & FACLO (lsb: $67 in C128, $65 in C64). The confusion here involves the use of three very similar routines- AYINT, QINT, and INT. Each does basically the same thing- INT(FAC), but with a few differences. Actually, both AYINT and INT call QINT. They all have left the result in the FAC somewhere since the beginning (same applies to the 8-bit Apples, too:-) AYINT provides some range checking (+32767 to -32768), then jumps to QINT, which leaves the result in FACMO & FACLO. INT calls QINT to remove any fractional part, then refloats the result in the FAC. QINT is the "Quick greatest INTeger" routine itself, leaving the result in FACMO & FACLO. I suspect the problem with C-power is some confusion between INT and QINT, from what Frank Prindle says. There is a difference between the C128 math pack and all earlier versions (PET, Apple, C64, etc.), but this fix is found in even the original C128 ROMs. INT now *rounds* the FAC before calling QINT. This fixes the Microsoft math bug where INT(.9 + .1) yeilds ZERO. Try it on your Apple, C64, and C128. Can I go home now? -- -- Fred Bowen uucp: {ihnp4|rutgers|caip}!cbmvax!fred arpa: cbmvax!fred@RUTGERS.EDU tele: 215 431-9100 Commodore Electronics, Ltd., 1200 Wilson Drive, West Chester, PA, 19380