better testing for small assembly (for coming changes)
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user