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, #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.



954
955
956
957
# File 'lib/ragweed/rasm/isa.rb', line 954

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

Instance Method Details

#mObject



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

def m; [nil,nil]; end

#to_sObject

Raises:



959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
# File 'lib/ragweed/rasm/isa.rb', line 959

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