Class: Ragweed::Rasm::Jmp

Inherits:
Instruction show all
Defined in:
lib/ragweed/rasm/isa.rb

Overview

Jump to a relative offset (pos or neg), a register, or an address in memory. Can take Labels instead of values, let patch figure out the rest.

Instance Attribute Summary

Attributes inherited from Instruction

#dst, #src

Instance Method Summary collapse

Methods inherited from Instruction

#add, #coerce, #dst_imm?, #dst_lab?, #dst_reg?, i, #locate, #modrm, #patch, #sib, #src_imm?, #src_lab?, #src_reg?

Constructor Details

#initialize(x = nil) ⇒ Jmp

eb rel8 e9 rel ff r/m no far yet



395
# File 'lib/ragweed/rasm/isa.rb', line 395

def initialize(x=nil); super x; end

Instance Method Details

#to_sObject

Raises:



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/ragweed/rasm/isa.rb', line 397

def to_s
  raise Insuff if not @dst
  if dst_imm? or dst_lab?
    if @dst.val < 0x100 and @dst.val > -127
      add(0xeb)
      add(@dst.val)
    else
      add(0xe9)
      add(@dst.val)
    end
  else
    add(0xff)
    add(modrm(@dst, Esp.clone))
    add(sx32(@dst.disp)) if @dst.disp
  end
  super
end