prindle@NADC.ARPA (11/06/87)
From: prindle@nadc.arpa (Frank Prindle) The BASIC ROM routine to convert integers to floating point is, as Fred Bowen says, alive and well. 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. Frank Prindle Prindle@NADC.arpa
fred@cbmvax.UUCP (Fred Bowen) (11/10/87)
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