diff --git a/dap-sdk/core/include/dap_math_ops.h b/dap-sdk/core/include/dap_math_ops.h index a751eaae997a0a85dbe3a7b527940a032da06800..2171c983c37b883e9bc384ee8d58f384f9a1eb13 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;