1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-17 16:29:32 +00:00

implement rsub

This commit is contained in:
mrdudz 2023-08-31 04:41:23 +02:00
parent ab238c1045
commit 26a3aa9fb7
6 changed files with 46 additions and 0 deletions

View File

@ -13,6 +13,7 @@
.import ___cbmkernal_fnegeax
.import ___cbmkernal_ftosaddeax
.import ___cbmkernal_ftossubeax
.import ___cbmkernal_ftosrsubeax
.import ___cbmkernal_ftosdiveax
.import ___cbmkernal_ftosmuleax
.import ___cbmkernal_ftoseqeax
@ -34,6 +35,7 @@
.export fnegeax := ___cbmkernal_fnegeax
.export ftosaddeax := ___cbmkernal_ftosaddeax
.export ftossubeax := ___cbmkernal_ftossubeax
.export ftosrsubeax := ___cbmkernal_ftosrsubeax
.export ftosdiveax := ___cbmkernal_ftosdiveax
.export ftosmuleax := ___cbmkernal_ftosmuleax
.export ftoseqeax := ___cbmkernal_ftoseqeax

View File

@ -224,6 +224,12 @@ ___cbmkernal_ftosdiveax:
___cbmkernal_ftosmuleax:
jmp __fmul
.import __frsub
; Primary = Primary - TOS
.export ___cbmkernal_ftosrsubeax
___cbmkernal_ftosrsubeax:
jmp __frsub
;--------------------------------------------------------------
.import __fcmp

View File

@ -659,6 +659,15 @@ __float_ret2:
jmp __float_ret2
.endmacro
.macro __ffunc2c addr
jsr ___float_float_to_fac_arg
jsr __float_swap_fac_arg
__enable_basic_if_needed
lda FAC_EXPONENT
jsr addr
jmp __float_ret2
.endmacro
.export __fadd, __fsub, __fmul, __fdiv, __fpow
; float __fastcall__ _fadd(float f, float a);
@ -674,6 +683,9 @@ __fpow: __ffunc2a BASIC_ARG_FAC_Pow
__fand: __ffunc2b BASIC_ARG_FAC_And
__for: __ffunc2b BASIC_ARG_FAC_Or
.export __frsub
__frsub: __ffunc2c BASIC_ARG_FAC_Sub
__float_ret3:
;jsr __basicoff
.if .defined(__C64__)

View File

@ -126,6 +126,12 @@ ftosdiveax:
; arg1: (sp),y (y=0..3)
jmp _float32_div
.import _float32_rsub
.export ftosrsubeax
ftosrsubeax:
; arg0: a/x/sreg/sreg+1
; arg1: (sp),y (y=0..3)
jmp _float32_rsub
.import _float32_eq
.import _float32_le

View File

@ -899,6 +899,25 @@ float32 __fastcall__ float32_sub( float32 a, float32 b ) // original
#endif
}
float32 __fastcall__ float32_rsub( float32 b, float32 a ) // swapped
{
#if 1
flag aSign, bSign;
aSign = extractFloat32Sign( a );
bSign = extractFloat32Sign( b );
if ( aSign == bSign ) {
return subFloat32Sigs( a, b, aSign );
}
else {
return addFloat32Sigs( a, b, aSign );
}
#else
b = b;
return a;
#endif
}
/*----------------------------------------------------------------------------
| Returns the result of multiplying the single-precision floating-point values
| `a' and `b'. The operation is performed according to the IEEE Standard for

View File

@ -91,6 +91,7 @@ float64 float32_to_float64( float32 );
float32 __fastcall__ float32_round_to_int( float32 );
float32 __fastcall__ float32_add( float32, float32 );
float32 __fastcall__ float32_sub( float32, float32 );
float32 __fastcall__ float32_rsub( float32, float32 );
float32 __fastcall__ float32_mul( float32, float32 );
float32 __fastcall__ float32_div( float32, float32 );
float32 __fastcall__ float32_rem( float32, float32 );