mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-22 23:29:27 +00:00
4ad7a65de6
This means that floating-point constants can now have the range and precision of the extended type (aka long double), and floating-point constant expressions evaluated within the compiler also have that same range and precision (matching expressions evaluated at run time). This new behavior is intended to match the behavior specified in the C99 and later standards for FLT_EVAL_METHOD 2. This fixes the previous problem where long double constants and constant expressions of type long double were not represented and evaluated with the full range and precision that they should be. It also gives extra range and precision to constants and constant expressions of type double or float. This may have pluses and minuses, but at any rate it is consistent with the existing behavior for expressions evaluated at run time, and with one of the possible models of floating point evaluation specified in the C standards.
222 lines
5.4 KiB
NASM
222 lines
5.4 KiB
NASM
mcopy cgc.macros
|
|
****************************************************************
|
|
*
|
|
* CnvSX - Convert floating point to SANE extended
|
|
*
|
|
* Inputs:
|
|
* rec - pointer to a record
|
|
*
|
|
****************************************************************
|
|
*
|
|
CnvSX start cg
|
|
rec equ 4 record containing values
|
|
rec_real equ 0 disp to real (extended) value
|
|
rec_ext equ 10 disp to extended (SANE) value
|
|
|
|
tsc set up DP
|
|
phd
|
|
tcd
|
|
ph4 rec push addr of real number
|
|
clc push addr of SANE number
|
|
lda rec
|
|
adc #rec_ext
|
|
tax
|
|
lda rec+2
|
|
adc #0
|
|
pha
|
|
phx
|
|
fx2x convert TOS to extended
|
|
move4 0,4 return
|
|
pld
|
|
pla
|
|
pla
|
|
rtl
|
|
end
|
|
|
|
****************************************************************
|
|
*
|
|
* CnvSC - Convert floating point to SANE comp
|
|
*
|
|
* Inputs:
|
|
* rec - pointer to a record
|
|
*
|
|
****************************************************************
|
|
*
|
|
CnvSC start cg
|
|
rec equ 4 record containing values
|
|
rec_real equ 0 disp to real (extended) value
|
|
rec_ext equ 10 disp to extended (SANE) value
|
|
rec_cmp equ 20 disp to comp (SANE) value
|
|
|
|
tsc set up DP
|
|
phd
|
|
tcd
|
|
ph4 rec push addr of real number
|
|
clc push addr of SANE comp number
|
|
lda rec
|
|
adc #rec_cmp
|
|
tax
|
|
lda rec+2
|
|
adc #0
|
|
pha
|
|
phx
|
|
fx2c convert TOS to SANE comp number
|
|
move4 0,4 return
|
|
pld
|
|
pla
|
|
pla
|
|
rtl
|
|
end
|
|
|
|
****************************************************************
|
|
*
|
|
* procedure CnvXLL (var result: longlong; val: extended);
|
|
*
|
|
* Convert floating point to long long
|
|
*
|
|
* Inputs:
|
|
* result - longlong to hold the converted value
|
|
* val - the real value
|
|
*
|
|
****************************************************************
|
|
|
|
CnvXLL start cg
|
|
|
|
subroutine (4:result,10:val),0
|
|
|
|
pei (val+8)
|
|
pei (val+6)
|
|
pei (val+4)
|
|
pei (val+2)
|
|
pei (val)
|
|
jsl ~CnvRealLongLong
|
|
pl8 [result]
|
|
|
|
return
|
|
end
|
|
|
|
****************************************************************
|
|
*
|
|
* procedure CnvXULL (var result: longlong; val: extended);
|
|
*
|
|
* Convert floating point to unsigned long long
|
|
*
|
|
* Inputs:
|
|
* result - longlong to hold the converted value
|
|
* val - the real value
|
|
*
|
|
****************************************************************
|
|
|
|
CnvXULL start cg
|
|
|
|
subroutine (4:result,10:val),0
|
|
|
|
pei (val+8)
|
|
pei (val+6)
|
|
pei (val+4)
|
|
pei (val+2)
|
|
pei (val)
|
|
jsl ~CnvRealULongLong
|
|
pl8 [result]
|
|
|
|
return
|
|
end
|
|
|
|
****************************************************************
|
|
*
|
|
* function CnvLLX (val: longlong): extended;
|
|
*
|
|
* convert a long long to a real number
|
|
*
|
|
* Inputs:
|
|
* val - the long long value
|
|
*
|
|
****************************************************************
|
|
|
|
CnvLLX start cg
|
|
|
|
subroutine (4:val),0
|
|
|
|
ph8 [val]
|
|
jsl ~CnvLongLongReal
|
|
pla
|
|
sta >rval
|
|
pla
|
|
sta >rval+2
|
|
pla
|
|
sta >rval+4
|
|
pla
|
|
sta >rval+6
|
|
pla
|
|
sta >rval+8
|
|
|
|
lla val,rval
|
|
return 4:val
|
|
|
|
rval ds 10
|
|
end
|
|
|
|
****************************************************************
|
|
*
|
|
* function CnvULLX (val: longlong): extended;
|
|
*
|
|
* convert an unsigned long long to a real number
|
|
*
|
|
* Inputs:
|
|
* val - the unsigned long long value
|
|
*
|
|
****************************************************************
|
|
|
|
CnvULLX start cg
|
|
|
|
subroutine (4:val),0
|
|
|
|
ph8 [val]
|
|
jsl ~CnvULongLongReal
|
|
pla
|
|
sta >rval
|
|
pla
|
|
sta >rval+2
|
|
pla
|
|
sta >rval+4
|
|
pla
|
|
sta >rval+6
|
|
pla
|
|
sta >rval+8
|
|
|
|
lla val,rval
|
|
return 4:val
|
|
|
|
rval ds 10
|
|
end
|
|
|
|
datachk off
|
|
****************************************************************
|
|
*
|
|
* InitLabels - initialize the labels array
|
|
*
|
|
* Outputs:
|
|
* labelTab - initialized
|
|
* intLabel - initialized
|
|
*
|
|
****************************************************************
|
|
*
|
|
InitLabels start cg
|
|
maxLabel equ 3200
|
|
|
|
! with labelTab[0] do begin
|
|
lda #-1 val := -1;
|
|
sta labelTab+6
|
|
sta labelTab+8
|
|
stz labelTab defined := false;
|
|
stz labelTab+2 chain := nil;
|
|
stz labelTab+4
|
|
! end; {with}
|
|
ldx #labelTab for i := 1 to maxLabel do
|
|
ldy #labelTab+10 labelTab[i] := labelTab[0];
|
|
lda #maxLabel*10-1
|
|
mvn labelTab,labelTab
|
|
stz intLabel intLabel := 0;
|
|
rtl
|
|
end
|