diff options
author | B. Watson <yalhcru@gmail.com> | 2016-01-14 17:59:58 -0500 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2016-01-14 17:59:58 -0500 |
commit | 06f2620ead18279afdd2501c3fef409252aa7ea0 (patch) | |
tree | 2ce3735ef6d39d973c270dd7bce161449c8ab7c7 | |
parent | f004009a5e52f617ef1f11639a1b810f687ffe2f (diff) | |
download | taipan-06f2620ead18279afdd2501c3fef409252aa7ea0.tar.gz |
big_copy() API for bignum
-rw-r--r-- | bignum.h | 2 | ||||
-rw-r--r-- | bignum.s | 22 | ||||
-rw-r--r-- | bigtest.c | 5 | ||||
-rw-r--r-- | taipan.c | 6 |
4 files changed, 23 insertions, 12 deletions
@@ -41,6 +41,8 @@ /* max value for a ulong */ #define BIG_MAX_ULONG { 0x44, 0x42, 0x94, 0x96, 0x72, 0x95 } +extern void __fastcall__ big_copy(bignump dest, bignump src); + // void int_to_big(int i, bignum *b); // void uint_to_big(unsigned int i, bignum *b); @@ -3,7 +3,7 @@ .importzp ptr3, ptr4, 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 + .export _bank_maxed_out, _big_cmp, _big_copy .include "atari.inc" @@ -34,15 +34,6 @@ fr0_to_fptemp: bpl @l rts -fr0_to_fr1: - ldx #5 -@l: - lda FR0,x - sta FR1,x - dex - bpl @l - rts - fptemp_to_fr0: ldx #5 @l: @@ -105,6 +96,17 @@ trunc_fr0: rts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; void __fastcall__ big_copy(bignump dest, bignump src) +_big_copy: + sta FLPTR ; src arg in FLPTR + stx FLPTR+1 + jsr FLD0P ; load src value into FR0 + jsr popax ; get dest arg + sta FLPTR ; dest arg in FLPTR + stx FLPTR+1 + jmp FST0P ; store FR0 value into dest + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; void __fastcall__ big_binary_op(bignump dest, bignump a, bignump b, unsigned int jsraddr); _big_binary_op: @@ -23,6 +23,8 @@ int main(void) { unsigned long got; bignum(a); bignum(b); + bignum(c); + bignum(zero) = BIG_0; ulong_to_big(1234L, a); ulong_to_big(10L, b); @@ -30,6 +32,9 @@ int main(void) { // printf("got %lu, mag %d\n", got, i); for(i = 0; i < 11; i++) { cprintfancy_big(a); + big_copy(c, zero); + big_copy(c, a); + cprintfancy_big(c); big_mul(a, a, b); } @@ -1287,7 +1287,8 @@ void cash_or_guns(void) cash = 1000000000L; // cash = 3500000L; #ifdef BIGNUM - memcpy(bank, big1M, 6); // FIXME: big_copy + big_copy(bank, big1M); + // memcpy(bank, big1M, 6); big_mul(bank, bank, big1M); #else bank = 1000000000L; @@ -2763,7 +2764,8 @@ void visit_bank(void) amount = get_num(); #ifdef BIGNUM if(amount == -1) { - memcpy(bigamt, bank, 6); // FIXME: big_copy + // memcpy(bigamt, bank, 6); + big_copy(bigamt, bank); } else { ulong_to_big(amount, bigamt); } |