diff options
-rw-r--r-- | CHANGELOG.txt | 6 | ||||
-rw-r--r-- | test.c | 6 | ||||
-rw-r--r-- | zap/GNUmakefile | 14 | ||||
-rw-r--r-- | zap/source/any/math/abs.c (renamed from zap/source/any/mth/abs.c) | 0 | ||||
-rw-r--r-- | zap/source/any/math/div0.c (renamed from zap/source/any/mth/div0.c) | 0 | ||||
-rw-r--r-- | zap/source/any/math/divmod.c (renamed from zap/source/any/mth/divmod.c) | 0 | ||||
-rw-r--r-- | zap/source/any/math/exp.c | 24 |
7 files changed, 44 insertions, 6 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 831e339..a6df51a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,9 @@ +# 16.3 + +* Implement exp; +* Fix bad directory name; +* Fix makefile; + # 16.2 * Implement cp and abs in AMD64; @@ -25,6 +25,12 @@ int main(void) { test(quotrem.quot,0xDu,==) test(quotrem.rem, 0x4u,==) } + { + /* 3^(-3) */ + zap_i02 const tmp = zap_exp04(0x3,0x3u); + zap_i02 const val = zap_divmod02(0x10000u,tmp).quot; + test(val,0x97Bu,==) + } /* mem */ { zap_i8 const src[0x3Fu] = { diff --git a/zap/GNUmakefile b/zap/GNUmakefile index 9c85885..c8993ff 100644 --- a/zap/GNUmakefile +++ b/zap/GNUmakefile @@ -14,6 +14,7 @@ OBJ_BS_TRAP := source/any/bs/trap.o OBJ_MATH_ABS := source/any/math/abs.o OBJ_MATH_DIV0 := source/any/math/div0.o OBJ_MATH_DIVMOD := source/any/math/divmod.o +OBJ_MATH_EXP := source/any/math/exp.o OBJ_MEM_CP := source/any/mem/cp.o OBJ_MEM_EQ := source/any/mem/eq.o OBJ_MEM_FILL := source/any/mem/fill.o @@ -26,8 +27,8 @@ OBJ_MEM_WIN1252DEC := source/any/mem/win1252dec.o OBJ_MEM_WIN1252ENC := source/any/mem/win1252enc.o ifeq "$(arch)" "amd64" -OBJ_MATH_ABS := source/$(arch)/math/abs -OBJ_MEM_CP := source/$(arch)/mem/cp.o.o +OBJ_MATH_ABS := source/$(arch)/math/abs.o +OBJ_MEM_CP := source/$(arch)/mem/cp.o else ifeq "$(arch)" "arm64" OBJ_MATH_ABS := source/$(arch)/math/abs OBJ_MEM_CP := source/$(arch)/mem/cp.o @@ -35,6 +36,10 @@ endif OBJS := \ $(OBJ_BS_TRAP) \ + $(OBJ_MATH_ABS) \ + $(OBJ_MATH_DIV0) \ + $(OBJ_MATH_DIVMOD) \ + $(OBJ_MATH_EXP) \ $(OBJ_MEM_CP) \ $(OBJ_MEM_EQ) \ $(OBJ_MEM_FILL) \ @@ -44,10 +49,7 @@ OBJS := \ $(OBJ_MEM_UTF8ENC) \ $(OBJ_MEM_UTF8ENCLEN) \ $(OBJ_MEM_WIN1252DEC) \ - $(OBJ_MEM_WIN1252ENC) \ - $(OBJ_MATH_ABS) \ - $(OBJ_MATH_DIV0) \ - $(OBJ_MATH_DIVMOD) + $(OBJ_MEM_WIN1252ENC) LIB := libzap.a diff --git a/zap/source/any/mth/abs.c b/zap/source/any/math/abs.c index d12b6a6..d12b6a6 100644 --- a/zap/source/any/mth/abs.c +++ b/zap/source/any/math/abs.c diff --git a/zap/source/any/mth/div0.c b/zap/source/any/math/div0.c index 87fcfa0..87fcfa0 100644 --- a/zap/source/any/mth/div0.c +++ b/zap/source/any/math/div0.c diff --git a/zap/source/any/mth/divmod.c b/zap/source/any/math/divmod.c index 4214651..4214651 100644 --- a/zap/source/any/mth/divmod.c +++ b/zap/source/any/math/divmod.c diff --git a/zap/source/any/math/exp.c b/zap/source/any/math/exp.c new file mode 100644 index 0000000..6c16213 --- /dev/null +++ b/zap/source/any/math/exp.c @@ -0,0 +1,24 @@ +/* + Copyright 2022-2023 Gabriel Jensen. + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>. +*/ + +#include <zap/math.h> + +#define zap_priv_exp(_wdth) \ +zap_i##_wdth zap_exp##_wdth(zap_i##_wdth const _val,zap_i##_wdth const _n) { \ + if (_val == 0x0) { \ + return 0x1u; \ + } \ + zap_i##_wdth val = _val; \ + for (zap_i##_wdth i = 0x1u;i < _n;++i) { \ + val *= _val; \ + } \ + return val; \ +} + +zap_priv_exp(8) +zap_priv_exp(01) +zap_priv_exp(02) +zap_priv_exp(04) |