Giter Site home page Giter Site logo

fasm-examples's Introduction

Linux x86_64 FASM Examples

Some more advanced and practical examples to demonstrate certain concepts I came across by experimenting and tinkering with fasm for ttyper. It uses standard c library for function calling like malloc, free, time etc.

Feel free to study, modify and play with them to see how fasm works, as I found little to no documentation to more advanced concepts like allocating memory and getting time difference.

A simpler examples can be found here.

Building

In order to build all the examples you can run

$ make

or build just a certain one

$ make malloc
$ make time 

and then run each of the example:

$ ./malloc
Value: 10
Value: 5

$ ./time
The elapsed time is 2 seconds

$ ./numbers
Number A: 1691
Number B: 42
Sum: 1733
Diff: 1649
Mul: 71022.00
Div: 40.26190
Mod: 11

Clearing up

To clear the build files, simply run

$ make clean

Linux x86_64 Calling Conventions

According to this, the register order for the syscalls is as follows: rdi, rsi, rdx, r10, r8, r9, and the result is put into rax.

Calling conventions for function calling, according to this post is as follows: rdi, rsi, rdx, rcx, r8 and r9

Contribution

I'm far from being a fasm expert and if you want to point out some mistakes or provide more examples, you're free to do so. I hope that will help not only me, but also other fasm newcomers that want to go beyond writing a hello world program.

The code is distributed under the MIT licence so feel free to use it as an example database for your tutoring.

fasm-examples's People

Contributors

noxonad avatar

Stargazers

 avatar

Watchers

 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.