https://github.com/davphla/minilibc
Lightweight C library that aims to recreate essential string and memory manipulation functions from the standard C library in assembly
https://github.com/davphla/minilibc
asm c makefile nasm
Last synced: about 1 year ago
JSON representation
Lightweight C library that aims to recreate essential string and memory manipulation functions from the standard C library in assembly
- Host: GitHub
- URL: https://github.com/davphla/minilibc
- Owner: Davphla
- Created: 2024-11-20T11:39:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-26T22:58:48.000Z (over 1 year ago)
- Last Synced: 2025-02-12T15:48:28.648Z (over 1 year ago)
- Topics: asm, c, makefile, nasm
- Language: C
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```
__ __ _ _ _ _ _
| \/ (_) (_) (_) |
| \ / |_ _ __ _| |_| |__ ___
| |\/| | | '_ \| | | | '_ \ / __|
| | | | | | | | | | | |_) | (__
|_| |_|_|_| |_|_|_|_|_.__/ \___|
```
# 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` :white_check_mark: — Calculate the length of a string.
- `strchr` :white_check_mark: — Locate the first occurrence of a character in a string.
- `strcmp` :white_check_mark: — Compare two strings.
- `strncmp` :white_check_mark: — Compare two strings up to a specified length.
- `strcasecmp` :white_check_mark: — Compare two strings ignoring case.
- `strstr` :white_check_mark: — Locate a substring within a string.
- `strpbrk` :white_check_mark: — Find the first occurrence of any character from a set.
- `strcspn` :white_check_mark: — Determine the length of a segment not containing specified characters.
- **Memory Manipulation**
- `memset` :white_check_mark: — Set a block of memory to a specific value.
- `memmove` :white_check_mark: — 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**:
```bash
git clone https://github.com/yourusername/minilibc.git
cd minilibc
```
2. **Build the Library**:
Ensure you have an appropriate assembler and compiler toolchain installed.
```bash
make
```
3. **Include Minilibc in Your Project**:
Link the `libasm.a` archive with your application during the build process:
```bash
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:
```c
#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](https://www.throwtheswitch.org/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.