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



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

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

Instance Method Details

#to_sObject

Raises:



1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
# File 'lib/ragweed/rasm/isa.rb', line 1095

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