This repository contains assembly code implementations of basic Math functions for x64 Windows. The functions are written in NASM (Netwide Assembler) and are designed to be used as part of a larger application or linked into other projects.
-
exp
double _exp(double a);
Returns the base-e exponential function of x, which is e raised to the power x: e^x.
-
exp2
int _exp2(int a);
Returns the base-2 exponential function of x, which is 2 raised to the power x: 2x.
-
expm1
double _expm1(double a);
Returns e raised to the power x minus one: e^x-1.
-
log
double _log(double a);
Returns the natural logarithm of x.
-
log10
double _log10(double a);
Returns the common (base-10) logarithm of x.
-
log2
double _log2(double a);
Returns the binary (base-2) logarithm of x.
-
pow
int _pow(int a, int b);
Returns base raised to the power exponent.
-
sqrt
int _sqrt(int a);
Returns the square root of x.
-
cbrt
int _cbrt(int a);
Returns the cubic root of x.
-
cos_function
double cos_function(double a);
Computes the cosine of a double-precision floating-point number.
-
sin_function
double sin_function(double a);
Computes the sine of a double-precision floating-point number.
-
tan_function
double sin_function(double a);
Computes the sine of a double-precision floating-point number.
-
is_greater
int is_greater(int a, int b);
Returns 1 if the first integer is greater than the second, otherwise returns 0.
-
is_greaterequal
int is_greaterequal(int a, int b);
Returns 1 if the first integer is greater than or equal to the second, otherwise returns 0.
-
is_less
int is_less(int a, int b);
Returns 1 if the first integer is less than the second, otherwise returns 0.
-
is_lessequal
int is_lessequal(int a, int b);
Returns 1 if the first integer is less than or equal to the second, otherwise returns 0.
-
is_lessgreater
int is_lessgreater(int a, int b);
Returns -1 if the first integer is less than the second, 0 if they are equal, and 1 if the first integer is greater than the second.
-
fmax
double fmax(double a, double b);
Returns the maximum of a and b.
-
fmin
double fmin(double a, double b);
Returns the minimum of a and b.
-
fdim
double fdim(double a, double b);
Returns the positive difference between x and y.
-
fabs
double fabs(double a);
Returns the absolute value of x: |x|.
-
abs
int _abs(int a);
Returns the absolute value of x: |x|.
-
fma
double fma(double a, double b, double c);
Returns x*y+z.
- Assemble the NASM code:
nasm -f win64 math.asm -o math.o
- Compile the C code:
gcc -c main.c -o main.o
- Link the object files and create the executable:
gcc main.o math.o -o main.exe
- Run the executable:
./main.exe