A hybrid C++/x86-64 Assembly library designed for high-efficiency arithmetic on integers of arbitrary size.
- Manual Memory Management: Implements the Rule of Three (Destructor, Copy Constructor, Copy Assignment) to manage raw memory on the heap.
- Assembly Kernels: Critical paths for addition and subtraction are written in x86-64 Assembly, utilizing the CPU's Carry Flag (CF).
- System V ABI Compliance: Seamlessy passes data between C++ and Assembly using standard register conventions (
RDI,RSI,RDX,RCX). - Optimized Data Layout: Stores numbers as a contiguous array of 64-bit blocks (quadwords), maximizing cache efficiency and CPU world alignment.
.
├── include/
│ └── BigInt.h # Class declarations & External ASM signatures
├── src/
│ ├── BigInt.cpp # C++ logic, memory management & operator wrappers
│ └── BigInt_x64.asm # Optimized x86-64 assembly implementation
├── tests/
│ ├── test_main.cpp # Unit tests for BigInt operations
│ └── test_asm_core.cpp # Direct testing of assembly primitives
├── Makefile # Automated build system
└── README.md
Unlike standard C++ which hides CPU status flags, this library directly utilizes the ADC (addition with carry) and SBB (subtraction with borrow) instructions. This allows
Numbers are represented as:
where
- NASM
- GCC/G++
- GNU Make
-
Clone the repository
git clone https://github.com/szampen/BigInt-Asm-Library.git cd BigInt-Asm-Library -
Build the project
make
-
Run core tests
./test_main ./test_zero_copy