Class: Ragweed::Rasm::Jcc

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

Overview

Wrapper for conditional jumps, see below

Direct Known Subclasses

Ja, Jae, Jb, Jbe, Jc, Je, Jg, Jge, Jl, Jle, Jna, Jnae, Jnb, Jnbe, Jnc, Jne, Jng, Jnge, Jnl, Jnle, Jno, Jnp, Jns, Jnz, Jo, Jp, Jpe, Jpo, Js, Jz

Instance Attribute Summary

Attributes inherited from Instruction

#dst, #src

Instance Method Summary collapse

Methods inherited from Instruction

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

Constructor Details

#initialize(dst) ⇒ Jcc

Returns a new instance of Jcc.



920
921
922
923
# File 'lib/ragweed/rasm/isa.rb', line 920

def initialize( dst)
  super dst
  @short, @near = m()
end

Instance Method Details

#mObject



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

def m; [nil,nil]; end

#to_sObject

Raises:



925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
# File 'lib/ragweed/rasm/isa.rb', line 925

def to_s
  raise Insuff if not @dst
  raise(BadArg, "need immed") if not dst_imm? and not dst_lab?

  if @dst.val < 0
    if @dst.val.abs & 0x80
      add(0x0f)
      add(@near)
      add(@dst.sx32)
    else
      add(@short)
      add(@dst.sx8)
    end
  else
    if @dst.val < 0x100
      add(@short)
      add(@dst.val)
    else
      add(0x0f)
      add(@near)
      add(@dst.val, true)
    end
  end
  super
end