Giter Site home page Giter Site logo

libft_asm's Introduction

Libft_ASM

The aim of this project is for me to learn more about x64 Assembly and at the side since Libft is used in
the school projects maybe I can have an excuse to use this and get some sort of performance gain from it. So far most functions seem to have some performance gain when compared to C version. Most notably ft_bzero is 10 times faster which is little mind boggling and makes me question if I can improve the C version. If anything, using optimization flags is kinda sometimes forbidden maybe (it's so hazy if it is or not and I'd rather not twist hands about it) so if I just write the assembly like -OX then it's fine right?
As more recent thing, I've been reading through AMD64 Architecture Programmer’s Manuals and picked up some fancy instructions and now I have a small subset of Libft_ASM original functions that use those instructions.
You will need Make and NASM to compile which you can grab from https://www.nasm.us/ or install through Linux packages. Just run make in terminal and you can link the libft_asm.a to your program. libft_asm.h is the related C header.
Do note that Windows passes arguments to functions in different registers than on Lunix/Mac so none of these actually work on Windows for now. Also interrupts in general are apparently a different world but that an issue for time when I have the first version done in its entirety.

TODO

  1. Create first versions of all basic Libft functions. Proper comments and descriptions included.
  2. Windows uses different registers to pass arguments to functions so port them over. It's a bit of work but most of the time it only involves swapping registers around.
  3. New functions! This is assembly and there's an entire world of things I can do here that are not implemented in C/C++ so I'm going to take full use of that.
  4. Own malloc. First I need to get the C version done but once that exists the ASM version should be easier to do since I have a proper ground to work on. I did some testing on just MMAP and it has massive overhead which I'm definitely not a fan of so I need the entire malloc around it.

Libft Functions

Function Name Done?
abs YES
atoi Kinda
atof YES
bzero YES
intsize YES
isalnum YES
isalpha YES
isascii YES
isblank YES
isdigit YES
isextascii X
isnegative YES
isprint YES
itoa X
lcm X
listlen YES
memalloc YES
memccpy YES
memchr YES
memcmp YES
memcpy YES
memdel YES
memmove YES
memset YES
printmem X
putchar YES
putchar_fd YES
putendl YES
putendl_fd YES
puthex YES
puthexln YES
putnbr X
putnbrln X
putnbr_fd X
putstr YES
putstr_fd YES
quadjoin YES
realloc Kinda
splitfree YES
strcat YES
strchr YES
strclr YES
strcmp YES
strcpy YES
strdel YES
strdup YES
strequ YES
strfjoin YES
striter YES
striteri YES
strjoin YES
strlcat YES
strlen YES
strmap X
strmapi X
strncat YES
strncmp YES
strncpy YES
strnequ YES
strnew X
strnstr YES
strrchr YES
strsjoin YES
strsplit X
strstr YES
strsub X
strtrim X
tolower YES
toupper YES
wordlen YES
get_next_line X

Libft_ASM Original Functions

Function Name Description
bswap Swaps byte order betweeen little and big endian
rotate_left Rotates num left by n bits. Overflow rolls back to right end
rotate_right Rotates num right by n bits. Overflow rolls back to left end

Issues

  1. Atoi doesn't follow the standard and skip over blank characters at the start.
  2. Realloc makes any further malloc uses sometimes crash with "malloc(): corrupted top size". The exact reason is unknown.

libft_asm's People

Contributors

alexwern avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.