renamed program to boot_space, as in object_space at boot time. thats the way its going

This commit is contained in:
Torsten Ruger
2014-05-31 12:52:29 +03:00
parent c9c484f353
commit 3713d08748
16 changed files with 110 additions and 27 deletions

View File

@ -9,12 +9,12 @@ require_relative 'helper'
class TestSmallProg < MiniTest::Test
# need a code generator, for arm
def setup
@program = Vm::Program.new "Arm"
@object_space = Vm::BootSpace.new "Arm"
end
def test_loop
r0 = Vm::Integer.new(0)
m = @program.main.scope binding
m = @object_space.main.scope binding
m.r0 = 5 #1
s = m.new_block("loop").scope binding
@ -26,13 +26,13 @@ class TestSmallProg < MiniTest::Test
def test_hello
hello = Vm::StringConstant.new "Hello Raisa\n"
@program.add_object hello
@object_space.add_object hello
# these are only here because it's a test program, usually all coding happens with values
r0 = Vm::Integer.new(0)
r1 = Vm::Integer.new(1)
r2 = Vm::Integer.new(2)
r7 = Vm::Integer.new(7)
b = @program.main.scope binding
b = @object_space.main.scope binding
b.r7 = 4 # 4 == write
b.r0 = 1 # stdout
b.r1 = hello # address of "hello Raisa"
@ -46,20 +46,20 @@ class TestSmallProg < MiniTest::Test
# not my hand off course, found in the net from a basic introduction
def test_fibo
int = Vm::Integer.new(1)
fibo = @program.get_or_create_function(:fibo)
main = @program.main.scope binding
fibo = @object_space.get_or_create_function(:fibo)
main = @object_space.main.scope binding
main.int = 10
ret = main.call( fibo )
main.mov( :r1 , :r7 )
putint = @program.get_or_create_function(:putint)
@program.main.call( putint )
putint = @object_space.get_or_create_function(:putint)
@object_space.main.call( putint )
@should = [0x0,0xb0,0xa0,0xe3,0xa,0x10,0xa0,0xe3,0x4,0x0,0x0,0xeb,0x7,0x10,0xa0,0xe1,0x22,0x0,0x0,0xeb,0x1,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x70,0xa0,0xe1,0x0,0x40,0x2d,0xe9,0x1,0x0,0x51,0xe3,0x1,0x70,0xa0,0xd1,0xe,0xf0,0xa0,0xd1,0x1c,0x40,0x2d,0xe9,0x1,0x30,0xa0,0xe3,0x0,0x40,0xa0,0xe3,0x2,0x20,0x41,0xe2,0x4,0x30,0x83,0xe0,0x4,0x40,0x43,0xe0,0x1,0x20,0x52,0xe2,0xfb,0xff,0xff,0x5a,0x3,0x70,0xa0,0xe1,0x1c,0x80,0xbd,0xe8,0x0,0x80,0xbd,0xe8,0x0,0x40,0x2d,0xe9,0xa,0x30,0x42,0xe2,0x22,0x21,0x42,0xe0,0x22,0x22,0x82,0xe0,0x22,0x24,0x82,0xe0,0x22,0x28,0x82,0xe0,0xa2,0x21,0xa0,0xe1,0x2,0x41,0x82,0xe0,0x84,0x30,0x53,0xe0,0x1,0x20,0x82,0x52,0xa,0x30,0x83,0x42,0x30,0x30,0x83,0xe2,0x0,0x30,0xc1,0xe5,0x1,0x10,0x41,0xe2,0x0,0x0,0x52,0xe3,0xef,0xff,0xff,0x1b,0x0,0x80,0xbd,0xe8,0x0,0x40,0x2d,0xe9,0x1,0x20,0xa0,0xe1,0x20,0x10,0x8f,0xe2,0x9,0x10,0x81,0xe2,0xe9,0xff,0xff,0xeb,0x14,0x10,0x8f,0xe2,0xc,0x20,0xa0,0xe3,0x1,0x0,0xa0,0xe3,0x4,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20]
write "fibo"
end
#helper to write the file
def write name
writer = Elf::ObjectWriter.new(@program , Elf::Constants::TARGET_ARM)
writer = Elf::ObjectWriter.new(@object_space , Elf::Constants::TARGET_ARM)
assembly = writer.text
# use this for getting the bytes to compare to :
#puts assembly