Giter Site home page Giter Site logo

libasm's Introduction

libasm

Some notes i aggregated while studying

Registers, what is each used for

Parameters

In order, 1st to 6th parameter.

rdi, rsi, rdx, rcx, r8, r9

subsequent ones stored on the LIFO stack

Data Registers

RAX, RBX, RCX, RDX

  • AX - ACCUMULATOR register, return values
  • BX - BASE register
  • CX - COUNT register, stores loop counts
  • DX - DATA register

Pointer Registers

RIP, RSP, RBP

  • IP - INSTRUCTION pointer, you cannot access this
  • SP - STACK pointer
  • BP - BASE pointer

Index Registers

RSI, RDI

  • SI - SOURCE index, used in string index operations
  • DI - DESTINATION index, used in string index operations

Caller vs Callee

All caller registers must b saved in a safe place before calling a function

register byte 0-3 bytes 0-1 byte 0 who saves
quadword doubleword word byte -
%rax %eax %ax %al Caller
%rbx %ecx %bx %bl Called Function
%rdi %edi %di %dil Caller (arg1)
%rsi %esi %si %sil Caller (arg2)
%rdx %edx %dx %dl Caller (arg3)
%rcx %ecx %cx %cl Caller (arg4)
%rsp %esp %sp %spl Stack ptr ?
%rbp %ebp %bp %bpl Called Function
%r8 %r8d %r8w r8b Caller (arg5)
%r9 %r9d %r9w r9b Caller (arg6)
%r10 %r10d %r10w r10b Caller
%r11 %r11d %r11w r11b Caller
%r12 %r12d %r12w r12b Called Function
%r13 %r13d %r13w r13b Called Function
%r14 %r14d %r14w r14b Called Function
%r15 %r15d %r15w r15b Called Function

Debugging tips

  • gdb a.out
  • tui enable
  • break (func, asm label, symbols)
  • layout regs or 'i r general' or 'disp /s $eax'
  • dereference value in gdb x/d $r12, x/s $r12 x/format $r12
  • run

libasm's People

Contributors

vln37 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.