Module: Ronin::Code::ASM::Archs::X86

Included in:
AMD64
Defined in:
lib/ronin/code/asm/archs/x86.rb

Overview

Contains X86 Architecture information.

Constant Summary collapse

WORD_SIZE =

Default word size

4
REGISTERS =

X86 registers

{
  al:  Register.new(:al, 1),
  ah:  Register.new(:ah, 1),
  ax:  Register.new(:ax, 2),
  eax: Register.new(:eax, 4, true),

  bl:  Register.new(:bl, 1),
  bh:  Register.new(:bh, 1),
  bx:  Register.new(:bx, 2),
  ebx: Register.new(:ebx, 4, true),

  cl:  Register.new(:cl, 1),
  ch:  Register.new(:ch, 1),
  cx:  Register.new(:cx, 2),
  ecx: Register.new(:ecx, 4, true),

  dl:  Register.new(:dl, 1),
  dh:  Register.new(:dh, 1),
  dx:  Register.new(:dx, 2),
  edx: Register.new(:edx, 4, true),

  bp:  Register.new(:bp, 2),
  ebp: Register.new(:ebp, 4),

  sp:  Register.new(:sp, 2),
  esp: Register.new(:esp, 4),

  ip:  Register.new(:ip, 2),
  eip: Register.new(:eip, 4),

  sil: Register.new(:sil, 1),
  si:  Register.new(:si, 2),
  esi: Register.new(:esi, 4, true),

  dil: Register.new(:dil, 1),
  di:  Register.new(:di, 2),
  edi: Register.new(:edi, 4, true),

  cs: Register.new(:cs, 2),
  ds: Register.new(:ds, 2),
  es: Register.new(:es, 2),
  fs: Register.new(:fs, 2),
  gs: Register.new(:gs, 2),
  ss: Register.new(:ss, 2)
}

Instance Method Summary collapse

Instance Method Details

#interrupt(number) ⇒ Object

Generates the instruction to trigger an interrupt.

Parameters:

  • number (Integer)

    The interrupt number.



87
# File 'lib/ronin/code/asm/archs/x86.rb', line 87

def interrupt(number); instruction(:int,number); end

#register_clear(name) ⇒ Object

Generates the instruction to clear a register.

Parameters:

  • name (Symbol)

    The name of the register.



130
131
132
# File 'lib/ronin/code/asm/archs/x86.rb', line 130

def register_clear(name)
  instruction(:xor,register(name),register(name))
end

#register_load(name) ⇒ Object

Generates the instruction to restore a register.

Parameters:

  • name (Symbol)

    The name of the register.



163
164
165
# File 'lib/ronin/code/asm/archs/x86.rb', line 163

def register_load(name)
  stack_pop(register(name))
end

#register_save(name) ⇒ Object

Generates the instruction to save a register.

Parameters:

  • name (Symbol)

    The name of the register.



153
154
155
# File 'lib/ronin/code/asm/archs/x86.rb', line 153

def register_save(name)
  stack_push(register(name))
end

#register_set(name, value) ⇒ Object

Generates the instruction to set a register.

Parameters:



143
144
145
# File 'lib/ronin/code/asm/archs/x86.rb', line 143

def register_set(name,value)
  instruction(:mov,value,register(name))
end

#stack_baseObject

The Stack Base Pointer register.

See Also:

  • ebp


99
# File 'lib/ronin/code/asm/archs/x86.rb', line 99

def stack_base; ebp; end

#stack_pointerObject

The Stack Pointer register.

See Also:

  • esp


106
# File 'lib/ronin/code/asm/archs/x86.rb', line 106

def stack_pointer; esp; end

#stack_pop(op) ⇒ Object

Generates the instruction to pop a value off of the Stack.

Parameters:

  • op (Register)

    The register operand to store the value.



122
# File 'lib/ronin/code/asm/archs/x86.rb', line 122

def stack_pop(op); instruction(:pop,op); end

#stack_push(op) ⇒ Object

Generates the instruction to push a value onto the Stack.

Parameters:



114
# File 'lib/ronin/code/asm/archs/x86.rb', line 114

def stack_push(op); instruction(:push,op); end

#syscallObject

Generates the instruction to invoke a syscall.



92
# File 'lib/ronin/code/asm/archs/x86.rb', line 92

def syscall; interrupt(0x80); end