Class: Ragweed::Rasm::Push

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

Overview

Push a register, register-addressed memory location, or immediate onto the stack.

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) ⇒ Push

ff r/m 50+ r 6a imm8 68 imm



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

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

Instance Method Details

#to_sObject

Raises:



452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'lib/ragweed/rasm/isa.rb', line 452

def to_s
  raise Insuff if not @dst

  if dst_reg?
    if @dst.indir
      add(0xff)
      add(modrm(@dst, Esi.clone))
      add(@dst.disp)
    else
      add(0x50 + @dst.code)
    end
  elsif dst_imm?
    if @dst.val < 0x100
      add(0x6a)
      add(@dst.val)
    else
      add(0x68)
      add(@dst.val)
    end
  end
  super
end