Class: Ragweed::Rasm::Int

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

Overview

INT 3, mostly, but will do INT X

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 = nil) ⇒ Int

cc int 3 cd imm int n ce int 4 notimp



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

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

Instance Method Details

#to_sObject

Raises:



1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/ragweed/rasm/isa.rb', line 1026

def to_s
  raise(TooMan, "too many arguments for int") if @src
  raise(BadArg, "int takes immed") if @dst and not dst_imm?

  if @dst
    raise(BadArg, "need 8 bit immed") if @dst.val >= 0x100
    if @dst.val == 3
      add(0xcc)
    elsif @dst.val == 4
      add(0xce)
    else
      add(0xcd)
      add(@dst.val)
    end
  else
    add(0xcc)
  end
  super
end