Class: Ragweed::Rasm::Mov
- Inherits:
-
Instruction
- Object
- Instruction
- Ragweed::Rasm::Mov
- Defined in:
- lib/ragweed/rasm/isa.rb
Overview
MOV, from reg to mem or v/v, or imm to reg, v/v
Instance Attribute Summary
Attributes inherited from Instruction
Instance Method Summary collapse
-
#initialize(x = nil, y = nil) ⇒ Mov
constructor
A new instance of Mov.
-
#to_s ⇒ Object
89 r/m, r 8b r, r/m b8+ r, imm c7+ r/m, imm.
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(x = nil, y = nil) ⇒ Mov
Returns a new instance of Mov.
811 |
# File 'lib/ragweed/rasm/isa.rb', line 811 def initialize( x=nil, y=nil); super x, y; end |
Instance Method Details
#to_s ⇒ Object
89 r/m, r 8b r, r/m b8+ r, imm c7+ r/m, imm
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
# File 'lib/ragweed/rasm/isa.rb', line 778 def to_s raise Insuff if not @src or not @dst raise NotImp if (src_reg? and @src.index) or (dst_reg? and @dst.index) if src_imm? if @dst.indir add(0xc7) add(@dst.code) add(@src.val) else add(0xb8 + @dst.code) add(@src.val, true) end elsif dst_imm? raise BadArg, "mov to immed" else raise(BadArg, "two r/m") if @src.indir and @dst.indir if not @src.indir and not @dst.indir add(0x89) add(modrm(@dst, @src)) elsif @src.indir # ie, ld add(0x8b) add(modrm(@dst, @src)) add(@src.disp) elsif @dst.indir # ie, st add(0x89) add(modrm(@dst, @src)) add(@dst.disp) end end super end |