diff options
-rw-r--r-- | bigfloat.s | 18 | ||||
-rw-r--r-- | bignum.h | 2 | ||||
-rw-r--r-- | taipan.c | 9 |
3 files changed, 20 insertions, 9 deletions
@@ -3,7 +3,7 @@ .importzp ptr3, sreg .import popeax, popax, pushax, _memcmp .export _ulong_to_big, _big_to_ulong, _big_add, _big_sub, _big_mul, _big_div - .export _bank_maxed_out, _big_cmp, _big_copy, _big_negate + .export _bank_maxed_out, _big_cmp, _big_copy ;, _big_negate .include "atari.inc" @@ -93,14 +93,14 @@ fptemp_to_fr1: ; void __fastcall__ big_negate(bignump b); ; This doesn't call the ROM or use FR0/FR1, it just inverts the sign ; bit in-place. -_big_negate: - sta ptr3 - stx ptr3+1 - ldy #0 - lda (ptr3),y - eor #$80 - sta (ptr3),y - rts +;_big_negate: +; sta ptr3 +; stx ptr3+1 +; ldy #0 +; lda (ptr3),y +; eor #$80 +; sta (ptr3),y +; rts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; truncate FR0 to integer (no rounding: 2.8 -> 2) @@ -89,7 +89,9 @@ extern char __cdecl__ big_mul(bignump dest, bignump multiplicand, bignump multip extern char __cdecl__ big_div(bignump dest, bignump dividend, bignump divisor); /* negation: b = -b, or b *= -1 */ +#if BIGNUM != BIGFLOAT extern void __fastcall__ big_negate(bignump b); +#endif /* returns true if the bank is maxed out. We do this by checking the exponent byte, so the "max" is tied to the bignum implementation, which is why its @@ -616,10 +616,19 @@ void cprintfancy_big(bignump b) { big_copy(tmp, b); + /* This is gross, but it saves 13 bytes here, plus another + 14 because we can remove big_negate from bigfloat.s. */ +#if BIGNUM == BIGFLOAT + if(tmp[0] & 0x80) { + cputc('-'); + tmp[0] ^= 0x80; + } +#else if(big_cmp(tmp, big0) < 0) { cputc('-'); big_negate(tmp); } +#endif if(big_cmp(tmp, big1T) >= 0) { // inverse "1 Trillion+!": |