Skip to content

High-perfomance big integer division library written in NASM assembly

License

Notifications You must be signed in to change notification settings

Iteron-dev/bigint-div

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BigInt Div library

Overview

A fast and space-efficient big int division library written in NASM assembly.

Exposed Function

int64_t mdiv(int64_t *x, size_t n, int64_t y);

Parameters:

  • x: Pointer to an array of n 64-bit integers representing the dividend in little-endian order.
  • n: Number of elements in the array x.
  • y: 64-bit signed integer divisor.

Returns:

  • The remainder of the division (x % y).
  • The quotient (x / y) is stored back in the array x.

Error Handling: In cases of overflow or division by zero, the function triggers an overflow condition (SIGFPE signal on Linux).

Limitations

  • The divisor (y) must be a signed 64-bit integer (int64_t).

Building and Running

Prerequisites:

  • For the library (mdiv.o):
    • NASM assembler
  • For the example program (example.c):
    • CMake version 3.30 or higher.
    • A C compiler supporting the C17 standard (e.g., GCC or Clang)
    • NASM assembler

Steps

  1. Clone the Repository:

    git clone https://github.com/Iteron-dev/bigint-div.git
    cd bigint-div
  2. Building the Library Only:

    To compile just the library (mdiv.o) for use in your own projects:

    nasm -f elf64 -w+all -w+error -o mdiv.o mdiv.asm
  3. Building the Example Program:

    To build the example program demonstrating the library usage:

    a) Using CMake:

    cmake -B build/
    make -C build/

    This will create the example executable in the build/ directory.

    b) Manual Compilation:

    If you prefer to compile manually without CMake:

    nasm -f elf64 -w+all -w+error -o mdiv.o mdiv.asm
    
    gcc -c -Wall -Wextra -std=c17 -O2 -o example.o example.c
    gcc -z noexecstack -o example example.o mdiv.o

Example Usage

For demonstration purposes, you can refer to and modify the example.c file. It showcases a sample usage of this library.

License

This project is licensed under the GNU General Public License v3.0.
See LICENSE for the full terms.

About

High-perfomance big integer division library written in NASM assembly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published