Skip to content

RaresRacsan/mathlib-C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Assembly Math Functions for x64 Windows

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.

Functions

Exponential and logaritmic functions

  1. exp

    double _exp(double a);

    Returns the base-e exponential function of x, which is e raised to the power x: e^x.

  2. exp2

    int _exp2(int a);

    Returns the base-2 exponential function of x, which is 2 raised to the power x: 2x.

  3. expm1

    double _expm1(double a);

    Returns e raised to the power x minus one: e^x-1.

  4. log

    double _log(double a);

    Returns the natural logarithm of x.

  5. log10

    double _log10(double a);

    Returns the common (base-10) logarithm of x.

  6. log2

    double _log2(double a);

    Returns the binary (base-2) logarithm of x.

Power functions

  1. pow

    int _pow(int a, int b);

    Returns base raised to the power exponent.

  2. sqrt

    int _sqrt(int a);

    Returns the square root of x.

  3. cbrt

    int _cbrt(int a);

    Returns the cubic root of x.

Trigonometric functions

  1. cos_function

    double cos_function(double a);

    Computes the cosine of a double-precision floating-point number.

  2. sin_function

    double sin_function(double a);

    Computes the sine of a double-precision floating-point number.

  3. tan_function

    double sin_function(double a);

    Computes the sine of a double-precision floating-point number.

Comparison functions

  1. is_greater

    int is_greater(int a, int b);

    Returns 1 if the first integer is greater than the second, otherwise returns 0.

  2. 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.

  3. is_less

    int is_less(int a, int b);

    Returns 1 if the first integer is less than the second, otherwise returns 0.

  4. 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.

  5. 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.

Minimum, maximum, difference functions

  1. fmax

    double fmax(double a, double b);

    Returns the maximum of a and b.

  2. fmin

    double fmin(double a, double b);

    Returns the minimum of a and b.

  3. fdim

    double fdim(double a, double b);

    Returns the positive difference between x and y.

Other functions

  1. fabs

    double fabs(double a);

    Returns the absolute value of x: |x|.

  2. abs

    int _abs(int a);

    Returns the absolute value of x: |x|.

  3. fma

    double fma(double a, double b, double c);

    Returns x*y+z.

Detailed compilation steps

  1. Assemble the NASM code:
nasm -f win64 math.asm -o math.o
  1. Compile the C code:
gcc -c main.c -o main.o
  1. Link the object files and create the executable:
gcc main.o math.o -o main.exe
  1. Run the executable:
./main.exe

Releases

No releases published

Packages

No packages published