diff --git a/CGC.asm b/CGC.asm index 6720205..a70587e 100644 --- a/CGC.asm +++ b/CGC.asm @@ -40,6 +40,9 @@ rec_ext equ 10 disp to extended (SANE) value * Inputs: * rec - pointer to a record * +* Note: This avoids calling FX2C on negative numbers, +* because it is buggy for certain values. +* **************************************************************** * CnvSC start cg @@ -51,6 +54,11 @@ rec_cmp equ 20 disp to comp (SANE) value tsc set up DP phd tcd + ldy #rec_real+8 + lda [rec],y + pha save sign of real number + and #$7fff + sta [rec],y set sign of real number to positive ph4 rec push addr of real number clc push addr of SANE comp number lda rec @@ -61,7 +69,32 @@ rec_cmp equ 20 disp to comp (SANE) value pha phx fx2c convert TOS to SANE comp number - move4 0,4 return + pla + bpl ret if real number was negative + ldy #rec_real+8 restore original sign of real number + sta [rec],y + sec negate the comp value + ldy #rec_cmp + ldx #0 + txa + sbc [rec],y + sta [rec],y + iny + iny + txa + sbc [rec],y + sta [rec],y + iny + iny + txa + sbc [rec],y + sta [rec],y + iny + iny + txa + sbc [rec],y + sta [rec],y +ret move4 0,4 return pld pla pla diff --git a/cc.notes b/cc.notes index 3d74c31..645b876 100644 --- a/cc.notes +++ b/cc.notes @@ -1575,6 +1575,8 @@ int foo(int[42]); 171. Function parameters declared with array types are adjusted to actually have pointer types, but this adjustment was not applied in some situations. Now such parameters are consistently treated as actually having pointer types. This affects their size as given by sizeof and their type as shown in debuggers. +172. When certain negative integers that are multiples of 65536 were converted from floating-point types to long, long long, or comp, an incorrect value might be produced due to a bug in SANE. ORCA/C now includes workarounds to avoid this bug in several situations, although it might still occur in certain other ones. + -- Bugs from C 2.1.0 that have been fixed ----------------------------------- 1. In some situations, fread() reread the first 1K or so of the file.