Skip to content

Lightweight C library that aims to recreate essential string and memory manipulation functions from the standard C library in assembly

Notifications You must be signed in to change notification settings

Davphla/Minilibc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

__  __ _       _ _ _ _          
|  \/  (_)     (_) (_) |         
| \  / |_ _ __  _| |_| |__   ___ 
| |\/| | | '_ \| | | | '_ \ / __|
| |  | | | | | | | | | |_) | (__ 
|_|  |_|_|_| |_|_|_|_|_.__/ \___|

Minilibc

Minilibc is a lightweight C library designed to reimplement key string and memory manipulation functions from the standard C library using assembly language.


Features

The following functions are fully implemented in assembly:

  • String Manipulation

    • strlen ✅ — Calculate the length of a string.
    • strchr ✅ — Locate the first occurrence of a character in a string.
    • strcmp ✅ — Compare two strings.
    • strncmp ✅ — Compare two strings up to a specified length.
    • strcasecmp ✅ — Compare two strings ignoring case.
    • strstr ✅ — Locate a substring within a string.
    • strpbrk ✅ — Find the first occurrence of any character from a set.
    • strcspn ✅ — Determine the length of a segment not containing specified characters.
  • Memory Manipulation

    • memset ✅ — Set a block of memory to a specific value.
    • memmove ✅ — Safely copy memory areas that may overlap.

Why Minilibc?

  • Lightweight: Focused on essential functionality without the overhead of a full standard library.
  • Educational: Ideal for learning about low-level programming and assembly language techniques.

Installation

  1. Clone the Repository:

    git clone https://github.com/yourusername/minilibc.git
    cd minilibc
  2. Build the Library: Ensure you have an appropriate assembler and compiler toolchain installed.

    make
  3. Include Minilibc in Your Project: Link the libasm.a archive with your application during the build process:

    gcc -o your_program your_program.c -L. -lasm

Usage

Include the relevant headers in your C code, then call the functions as you would with the standard library:

#include "minilibc.h"

int main() {
    char str[] = "Hello, world!";
    size_t len = strlen(str);
    printf("Length: %zu\n", len);
    return 0;
}

Roadmap

Completed

  • Core functions implemented:
    • strlen, strchr, memset, strcmp, memmove, strncmp, strcasecmp, strstr, strpbrk, strcspn.

TODO

  • Add Unit Testing: Implement testing using Unity to ensure function correctness.
  • Release Library on GitHub: Provide pre-built binaries and documentation.
  • Add SIMD Optimization: Extend functionality with libsimd for enhanced performance.

About

Lightweight C library that aims to recreate essential string and memory manipulation functions from the standard C library in assembly

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published