translate and interpret new instructions
This commit is contained in:
parent
ac5a7ac4ca
commit
249f43ad34
@ -31,6 +31,12 @@ module Arm
|
||||
ArmMachine.str( :lr , code.register , arm_index(code) )
|
||||
end
|
||||
|
||||
def translate_RegisterTransfer code
|
||||
# Register machine convention is from => to
|
||||
# But arm has the receiver/result as the first
|
||||
ArmMachine.mov( code.to , code.from)
|
||||
end
|
||||
|
||||
def translate_GetSlot code
|
||||
# times 4 because arm works in bytes, but vm in words
|
||||
if(code.index.is_a? Numeric)
|
||||
@ -40,12 +46,6 @@ module Arm
|
||||
end
|
||||
end
|
||||
|
||||
def translate_RegisterTransfer code
|
||||
# Register machine convention is from => to
|
||||
# But arm has the receiver/result as the first
|
||||
ArmMachine.mov( code.to , code.from)
|
||||
end
|
||||
|
||||
def translate_SetSlot code
|
||||
# times 4 because arm works in bytes, but vm in words
|
||||
if(code.index.is_a? Numeric)
|
||||
@ -55,6 +55,22 @@ module Arm
|
||||
end
|
||||
end
|
||||
|
||||
def translate_GetByte code
|
||||
if(code.index.is_a? Numeric)
|
||||
ArmMachine.ldrb( code.register , code.array , arm_index(code) )
|
||||
else
|
||||
ArmMachine.ldrb( code.register , code.array , code.index )
|
||||
end
|
||||
end
|
||||
|
||||
def translate_SetByte code
|
||||
if(code.index.is_a? Numeric)
|
||||
ArmMachine.strb( code.register , code.array , arm_index(code) )
|
||||
else
|
||||
ArmMachine.strb( code.register , code.array , code.index )
|
||||
end
|
||||
end
|
||||
|
||||
def translate_FunctionCall code
|
||||
ArmMachine.b( code.method.instructions )
|
||||
end
|
||||
|
@ -148,6 +148,36 @@ module Register
|
||||
true
|
||||
end
|
||||
|
||||
def execute_GetByte
|
||||
object = get_register( @instruction.array )
|
||||
if( @instruction.index.is_a?(Numeric) )
|
||||
index = @instruction.index
|
||||
else
|
||||
index = get_register(@instruction.index)
|
||||
end
|
||||
if object.is_a?(Symbol)
|
||||
raise "Unsupported action, must convert symbol to word:#{object}"
|
||||
else
|
||||
value = object.get_internal_byte( index )
|
||||
end
|
||||
#value = value.object_id unless value.is_a? Fixnum
|
||||
set_register( @instruction.register , value )
|
||||
true
|
||||
end
|
||||
|
||||
def execute_SetByte
|
||||
value = get_register( @instruction.register )
|
||||
object = get_register( @instruction.array )
|
||||
if( @instruction.index.is_a?(Numeric) )
|
||||
index = @instruction.index
|
||||
else
|
||||
index = get_register(@instruction.index)
|
||||
end
|
||||
object.set_internal_byte( index , value )
|
||||
trigger(:object_changed, @instruction.array , index / 4 )
|
||||
true
|
||||
end
|
||||
|
||||
def execute_RegisterTransfer
|
||||
value = get_register @instruction.from
|
||||
set_register @instruction.to , value
|
||||
|
@ -28,6 +28,7 @@ return w.char_at(1)
|
||||
HERE
|
||||
check_return 32
|
||||
end
|
||||
|
||||
def test_after_add_get_works
|
||||
@main = <<HERE
|
||||
Word w = " "
|
||||
@ -61,4 +62,14 @@ return w.char_at(2)
|
||||
HERE
|
||||
check_return 50
|
||||
end
|
||||
|
||||
def test_set2
|
||||
@main = <<HERE
|
||||
Word w = "12345"
|
||||
w.set_char_at(2 , 51)
|
||||
return w.char_at(2)
|
||||
HERE
|
||||
check_return 51
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user