mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2025-02-07 04:30:31 +00:00
Add a function to implement the FP comparison macros in <math.h>.
These macros differ from the normal comparison operators in that they will not signal invalid due to the operands being unordered. However, this implementation will still signal invalid for SNaNs. That is clearly OK according to the wording in draft C23. C17 and earlier do not mention that possibility, but they do not really specify the behavior of SNaNs in general.
This commit is contained in:
parent
b8605de33f
commit
fb5683a14d
41
math2.asm
41
math2.asm
@ -153,3 +153,44 @@ __signbit start
|
||||
|
||||
creturn 2:val
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* int __fpcompare(long double x, long double y, short mask);
|
||||
*
|
||||
* Compare two floating-point values, not signaling invalid
|
||||
* if they are unordered.
|
||||
*
|
||||
* Inputs:
|
||||
* x,y - values to compare
|
||||
* mask - mask of bits as returned in X register from FCMP
|
||||
*
|
||||
* Outputs:
|
||||
* 1 if x and y have one of the relations specified by mask
|
||||
* 0 otherwise
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
__fpcompare start
|
||||
|
||||
csubroutine (10:x,10:y,2:mask),0
|
||||
|
||||
tdc
|
||||
clc
|
||||
adc #x
|
||||
pea 0
|
||||
pha
|
||||
tdc
|
||||
clc
|
||||
adc #y
|
||||
pea 0
|
||||
pha
|
||||
FCMPX
|
||||
txa
|
||||
and mask
|
||||
beq lb1
|
||||
lda #1
|
||||
lb1 sta mask
|
||||
|
||||
creturn 2:mask
|
||||
end
|
||||
|
@ -121,3 +121,9 @@
|
||||
LDX #$090A
|
||||
JSL $E10000
|
||||
MEND
|
||||
MACRO
|
||||
&LAB FCMPX
|
||||
&LAB PEA $08
|
||||
LDX #$090A
|
||||
JSL $E10000
|
||||
MEND
|
||||
|
Loading…
x
Reference in New Issue
Block a user