Class: Ragweed::Rasm::Test

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

Overview

Test is AND + condition code

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 = nil, src = nil) ⇒ Test

a8 imm8 a9 imm f7/0, r/m 85 r/m, r



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

def initialize( dst=nil, src=nil); super(dst,src); end

Instance Method Details

#to_sObject



679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/ragweed/rasm/isa.rb', line 679

def to_s
  if not @dst
    raise(BadArg, "need imm for implied ax") if not src_imm?
    if @src.val < 0x100
      add(0xa8)
      add(@src.val)
    else
      add(0xa9)
      add(@src.val)
    end
  else
    if src_imm?
      add(0xf7)
      add(modrm(@dst.val, Eax.clone))
      add(@src.val)
    else
      add(0x85)
      add(modrm(@dst.val, @src))
    end
  end
  super
end