Giter VIP home page Giter VIP logo

libasm's Introduction

libasm

Description

This project is about creating an asm library called libasm.a.
It contains implementations of the following functions in asm with Intel syntax:

◦ ft_strlen (man 3 strlen)
◦ ft_strcpy (man 3 strcpy)
◦ ft_strcmp (man 3 strcmp)
◦ ft_write (man 2 write)
◦ ft_read (man 2 read)
◦ ft_strdup (man 3 strdup)

It also includes a main.c which contains a tester.

Notes on register preservation

Another part of a calling convention is which registers are guaranteed to retain their values after a subroutine call.

Caller-saved volatile registers

  • According to the Intel ABI to which the vast majority of compilers conform:
    RAX, RCX, RDX, R8, R9, R10, R11 are considered volatile (caller-saved).
  • These registers are to be free for use within a procedure or function, and need not be preserved
  • As the name implies, these general-purpose registers usually hold temporary (volatile) information, that can be overwritten by any subroutine.
  • Therefore, it is the caller's responsibility to push each of these registers onto the stack, if it would like to restore their values after a subroutine call.

Callee-saved non-volatile registers

  • The other registers are used to hold long-lived values (non-volatile), that should be preserved across calls:
    RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15 are considered nonvolatile (callee-saved).
  • When the caller makes a procedure call, it can expect that those registers will hold the same value after the callee returns.
  • Thus, making it the callee's responsibility to both save (push at the beginning) and restore (pop accordingly) them before returning to the caller. As in the previous case, this practice should only be done on registers that the callee changes.

Useful commands

// Display a table listing the contents of archive
ar t libasm.a

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.