From 6d9e07fa85103d5de07bdf9eff3fba2a83dfb60c Mon Sep 17 00:00:00 2001 From: Evgeniy Kramsakov <evgeniy.kramsakov@demlabs.net> Date: Fri, 9 Sep 2022 13:41:29 +0300 Subject: [PATCH] [*] fix decr_128 and add missing decr_256 --- dap-sdk/core/include/dap_math_ops.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/dap-sdk/core/include/dap_math_ops.h b/dap-sdk/core/include/dap_math_ops.h index a751eaae99..2171c983c3 100755 --- a/dap-sdk/core/include/dap_math_ops.h +++ b/dap-sdk/core/include/dap_math_ops.h @@ -317,11 +317,11 @@ static inline void DECR_128(uint128_t* a_128_bit){ (*a_128_bit)--; #else + if (a_128_bit->lo == 0) { + a_128_bit->hi--; + } a_128_bit->lo--; - if(a_128_bit->hi == 0) - { - a_128_bit->hi--; - } + #endif } @@ -343,6 +343,20 @@ static inline void INCR_256(uint256_t* a_256_bit){ #endif } +static inline void DECR_256(uint256_t* a_256_bit) { +#ifdef DAP_GLOBAL_IS_INT128 + if (a_256_bit->lo == 0) { + a_256_bit->hi--; + } + a_256_bit->lo--; +#else + if(EQUAL_128(a_256_bit->lo, uin128_0)) { + DECR_128(&a_256_bit->hi); + } + DECR_128(&a_256_bit->lo); +#endif +} + static inline int SUM_64_64(uint64_t a_64_bit,uint64_t b_64_bit,uint64_t* c_64_bit ) { int overflow_flag; -- GitLab