Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
/ libasm Public archive

🧩 Tiny functions library using assembly language. It includes: ft_strlen, ft_strcmp, ft_strcpy, ft_strdup, ft_read and ft_write. Two last also set errno value in case of error

Notifications You must be signed in to change notification settings

romanwrites/libasm

Repository files navigation

libasm

Title libasm

Photo by Andreas M on Unsplash

Tiny library written on assembly language

Includes:

And tests: main.c

Install

git clone https://github.com/kukinpower/libasm.git && cd

make

Compile and run with tests: make main

Research

x86-64 64bit Registers: Usage Conventions

rax     ; Return value
rbx     ; Callee saved
rcx     ; Arg 4
rdx     ; Arg 3
rsi     ; Arg 2
rdi     ; Arg 1
rsp     ; Stack ptr
rbp     ; Callee saved
r8      ; Arg 5
r9      ; Arg 6
r10     ; Caller saved
r11     ; Caller saved
r12     ; Callee saved
r13     ; Callee saved
r14     ; Callee saved
r15     ; Callee saved

Jumps

jmp     ; Unconditional Jump
je      ; Jump if Equal
jne     ; Jump if Not Equal
jg      ; Jump if Greater
jge     ; Jump if Greater or Equal
ja      ; Jump if Above (unsigned comparison)
jae     ; Jump if Above or Equal (unsigned comparison)
jl      ; Jump if Lesser
jle     ; Jump if Less or Equal
jb      ; Jump if Below (unsigned comparison)
jz      ; Jump if Zero
jnz     ; Jump if Not Zero
jc      ; Jump if carry set (C == 1)
jnc     ; Jump if carry is not set (C == 0)

Little endian and big endian
Little endian and big endian

Скриншот книги Введение в программирование, Столяров.

NASM Tutorial

x86_64 NASM Assembly Quick Reference ("Cheat Sheet")

strlen() implementation in NASM

Difference between JE/JNE and JZ/JNZ

Assembly - Conditions

Mac OS X 64 bit Assembly System Calls

How to compile assembly code

nasm -f macho64 hello.s
ld -e start -macosx_version_min 10.13.0 -static -o hello hello.o
./hello

About

🧩 Tiny functions library using assembly language. It includes: ft_strlen, ft_strcmp, ft_strcpy, ft_strdup, ft_read and ft_write. Two last also set errno value in case of error

Topics

Resources

Stars

Watchers

Forks