add to_asm debug output functions
This commit is contained in:
parent
dcd691fe00
commit
017d93d929
@ -22,6 +22,9 @@ module Vm
|
||||
def value
|
||||
@integer
|
||||
end
|
||||
def to_asm
|
||||
@integer.to_s
|
||||
end
|
||||
end
|
||||
|
||||
# The name really says it all.
|
||||
|
@ -90,7 +90,7 @@ module Vm
|
||||
@first
|
||||
end
|
||||
def to_s
|
||||
"#{opcode} #{@first} #{super}"
|
||||
"#{opcode} [#{@first.collect {|f| f.to_asm}.join(',') }] #{super}"
|
||||
end
|
||||
end
|
||||
class MemoryInstruction < Instruction
|
||||
@ -131,8 +131,8 @@ module Vm
|
||||
def assigns
|
||||
[@result.used_register]
|
||||
end
|
||||
def to_s
|
||||
"#{opcode} #{result.register_symbol} , #{left.register_symbol} , #{right.register_symbol} #{super}"
|
||||
def to_asm
|
||||
"#{opcode} #{result.to_asm} , #{left.to_asm} , #{right.to_asm} #{super}"
|
||||
end
|
||||
end
|
||||
class CompareInstruction < Instruction
|
||||
@ -165,7 +165,7 @@ module Vm
|
||||
[@to.used_register]
|
||||
end
|
||||
def to_s
|
||||
"#{opcode} #{@to.register_symbol} , #{@from.is_a?(Constant) ? @from.value : @from.register_symbol} #{super}"
|
||||
"#{opcode} #{@to.to_asm} , #{@from.to_asm} #{super}"
|
||||
end
|
||||
end
|
||||
class CallInstruction < Instruction
|
||||
|
@ -103,6 +103,10 @@ module Vm
|
||||
def length
|
||||
4
|
||||
end
|
||||
# aka to string
|
||||
def to_asm
|
||||
"#{register_symbol}"
|
||||
end
|
||||
end
|
||||
|
||||
class Unsigned < Word
|
||||
@ -169,7 +173,6 @@ module Vm
|
||||
block.mov( self , right )
|
||||
self
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
require_relative "constants"
|
@ -28,9 +28,9 @@ end
|
||||
|
||||
t_seven()
|
||||
HERE
|
||||
@should = [0x0,0x40,0x2d,0xe9,0x2,0x30,0x41,0xe0,0x3,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8,0x0,0x40,0x2d,0xe9,0x2,0x30,0x41,0xe0,0x3,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8]
|
||||
@should = [0x0,0x40,0x2d,0xe9,0x0,0x0,0x54,0xe3,0x10,0x0,0x0,0xa,0x8,0x0,0x2d,0xe9,0x4,0x30,0xa0,0xe1,0x1,0x40,0xa0,0xe3,0xf2,0xff,0xff,0xeb,0x8,0x0,0xbd,0xe8,0x0,0x50,0xa0,0xe1,0x8,0x0,0x2d,0xe9,0x5,0x40,0xa0,0xe1,0xf3,0xff,0xff,0xeb,0x8,0x0,0xbd,0xe8,0x0,0x60,0xa0,0xe1,0x10,0x0,0x2d,0xe9,0x6,0x40,0xa0,0xe1,0xeb,0xff,0xff,0xeb,0x10,0x0,0xbd,0xe8,0x0,0x30,0xa0,0xe1,0x0,0x0,0x0,0xea,0x0,0x30,0xa0,0xe3,0x3,0x0,0xa0,0xe1,0x0,0x80,0xbd,0xe8]
|
||||
@output = " 42 "
|
||||
@target = [:Object , :minus]
|
||||
@target = [:Object , :times]
|
||||
parse
|
||||
write "functions"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user