aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2021-03-25 15:14:25 -0400
committerB. Watson <yalhcru@gmail.com>2021-03-25 15:14:25 -0400
commit47ce755193d18704ffaf9dc3e5953dd6966f1db1 (patch)
tree9fe93ec785dd26062459563c008db5db4194a1d9
parentea2d5014ade974ca99678d3aac36ebd4c8e4d8c6 (diff)
downloadtaipan-47ce755193d18704ffaf9dc3e5953dd6966f1db1.tar.gz
Save 27 bytes
-rw-r--r--bigfloat.s18
-rw-r--r--bignum.h2
-rw-r--r--taipan.c9
3 files changed, 20 insertions, 9 deletions
diff --git a/bigfloat.s b/bigfloat.s
index d3115bc..2d30855 100644
--- a/bigfloat.s
+++ b/bigfloat.s
@@ -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)
diff --git a/bignum.h b/bignum.h
index 06fbd8b..4eed63e 100644
--- a/bignum.h
+++ b/bignum.h
@@ -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
diff --git a/taipan.c b/taipan.c
index d1cb8ed..d7aa888 100644
--- a/taipan.c
+++ b/taipan.c
@@ -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+!":