Giter VIP home page Giter VIP logo

assemblysamples's Introduction

Mac OS x64 Assembler Samples

Registers

64-bit register Lower 32 bits Lower 16 bits Lower 8 bits
r(a b c d)x
rsi esi si sil
rdi edi di dil
rbp ebp bp bpl
rsp esp sp spl
r(8-15) r(8-15)d r(8-15)w r(8-15)b

Data types

  • byte - 1 byte
  • word - 2 bytes
  • doubleword/long - 4 bytes
  • quadword/quad - 8 bytes

Instructions

Suffixes (Apple syntax): w - word, l - long, q - quad

Instruction Description
mov D, S Move source to destination
lea D, S Load effective address of source into destination
syscall Perform syscall, described later

Utils

  • Get address of data: variable_name(%rip)

Syscall

Syscall constants

To perform syscall find it number here: /usr/include/sys/syscall.h or /Library/Developer/CommandLineTools/SDKs/MacOSX.?.sdk/usr/include/sys/syscall.h

Data type representation

  • int: 32 bit / 4 byte (signed)
  • void, size_t: 64bit / 8 byte (unsigned)
  • ssize_t: 64bit / 8 byte (signed)

Execution

Put syscall number in %eax with offset 0x2000000

Parameters should be in %rdi, %rsi, %rdx, %r10, %r8 and %r9

Return value is %rax

Syscall declarations

  • void exit(int exit_code)
  • ssize_t read(int fd, void *buf, size_t count);
  • ssize_t write(int fd, const void *buf, size_t count)

assemblysamples's People

Contributors

konh avatar

Stargazers

 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.