better testing for small assembly (for coming changes)

This commit is contained in:
Torsten Ruger
2014-05-20 10:29:08 +03:00
parent 0fa47d204e
commit fcf76eed34
4 changed files with 24 additions and 10 deletions

View File

@ -14,6 +14,12 @@ module Elf
Elf::Constants::SHF_WRITE | Elf::Constants::SHF_ALLOC | Elf::Constants::SHF_EXECINSTR
end
def length
@text.length
end
def to_s
"[" + @text.bytes.join(",") + "]"
end
def alignment
4
end

View File

@ -63,6 +63,9 @@ module Vm
end
end
def at where
@current = where
end
# set the next executed block after self.
# why is this useful? if it's unconditional, why not merge them:
# So the second block can be used as a jump target. You standard loop needs a block to setup
@ -74,7 +77,10 @@ module Vm
# sugar to create instructions easily. Any method with one arg is sent to the machine and the result
# (hopefully an instruction) added as code
def method_missing(meth, *args, &block)
raise "hallo" if( meth.to_s[-1] == "=")
if( meth.to_s[-1] == "=")
val = @current.eval meth.to_s[0 ... -1]
raise "hallo #{val}"
end
add_code CMachine.instance.send(meth , *args)
end