removed the (too) fancy dsl. Also introduce register indirection
This commit is contained in:
@ -21,7 +21,8 @@ def minus(a,b)
|
||||
end
|
||||
end
|
||||
|
||||
putint(times(7,6))
|
||||
tim = times(7,6)
|
||||
tim.putint()
|
||||
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]
|
||||
@output = " 42 "
|
||||
|
@ -5,7 +5,8 @@ class TestPutint < MiniTest::Test
|
||||
|
||||
def test_putint
|
||||
@string_input = <<HERE
|
||||
putint( 42 )
|
||||
fourty_two = 42
|
||||
fourty_two.putint()
|
||||
HERE
|
||||
@should = [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,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]
|
||||
@output = " 42 "
|
||||
@ -14,4 +15,3 @@ HERE
|
||||
write "putint"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,8 +14,8 @@ def fibonaccir( n )
|
||||
return a + b
|
||||
end
|
||||
end
|
||||
|
||||
putint(fibonaccir( 10 ))
|
||||
fib = fibonaccir( 10 )
|
||||
fib.putint()
|
||||
HERE
|
||||
@should = [0x0,0x40,0x2d,0xe9,0x1,0x0,0x51,0xe3,0xe,0x0,0x0,0xda,0x1,0x20,0x41,0xe2,0x6,0x0,0x2d,0xe9,0x2,0x10,0xa0,0xe1,0xf8,0xff,0xff,0xeb,0x6,0x0,0xbd,0xe8,0x7,0x30,0xa0,0xe1,0x2,0x40,0x41,0xe2,0x1e,0x0,0x2d,0xe9,0x4,0x10,0xa0,0xe1,0xf2,0xff,0xff,0xeb,0x1e,0x0,0xbd,0xe8,0x7,0x50,0xa0,0xe1,0x5,0x60,0x83,0xe0,0x6,0x70,0xa0,0xe1,0x0,0x0,0x0,0xea,0x1,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8,0x0,0x40,0x2d,0xe9,0x1,0x0,0x51,0xe3,0xe,0x0,0x0,0xda,0x1,0x20,0x41,0xe2,0x6,0x0,0x2d,0xe9,0x2,0x10,0xa0,0xe1,0xf8,0xff,0xff,0xeb,0x6,0x0,0xbd,0xe8,0x7,0x30,0xa0,0xe1,0x2,0x40,0x41,0xe2,0x1e,0x0,0x2d,0xe9,0x4,0x10,0xa0,0xe1,0xf2,0xff,0xff,0xeb,0x1e,0x0,0xbd,0xe8,0x7,0x50,0xa0,0xe1,0x5,0x60,0x83,0xe0,0x6,0x70,0xa0,0xe1,0x0,0x0,0x0,0xea,0x1,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8]
|
||||
@output = " 55 "
|
||||
|
@ -16,8 +16,8 @@ def fibonaccit(n) # n == r0
|
||||
end #r5 <- r0 - 1 n=n-1 through r5 tmp
|
||||
return b
|
||||
end # r0 <- r5
|
||||
|
||||
putint(fibonaccit( 10 ))
|
||||
fibo = fibonaccit( 10 )
|
||||
fibo.putint()
|
||||
HERE
|
||||
@should = [0x0,0x40,0x2d,0xe9,0x0,0x20,0xa0,0xe3,0x1,0x30,0xa0,0xe3,0x1,0x0,0x51,0xe3,0x6,0x0,0x0,0xda,0x2,0x40,0xa0,0xe1,0x3,0x20,0xa0,0xe1,0x3,0x50,0x84,0xe0,0x5,0x30,0xa0,0xe1,0x1,0x60,0x41,0xe2,0x6,0x10,0xa0,0xe1,0xf6,0xff,0xff,0xea,0x3,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8,0x0,0x40,0x2d,0xe9,0x0,0x20,0xa0,0xe3,0x1,0x30,0xa0,0xe3,0x1,0x0,0x51,0xe3,0x6,0x0,0x0,0xda,0x2,0x40,0xa0,0xe1,0x3,0x20,0xa0,0xe1,0x3,0x50,0x84,0xe0,0x5,0x30,0xa0,0xe1,0x1,0x60,0x41,0xe2,0x6,0x10,0xa0,0xe1,0xf6,0xff,0xff,0xea,0x3,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8]
|
||||
@output = " 55 "
|
||||
@ -31,8 +31,8 @@ HERE
|
||||
def test_kernel_fibo
|
||||
int = Vm::Integer.new(1)
|
||||
fibo = @object_space.get_or_create_class(:Object).get_or_create_function(:fibo)
|
||||
main = @object_space.main.scope binding
|
||||
main.int = 10
|
||||
main = @object_space.main
|
||||
main.mov int , 10
|
||||
ret = main.call( fibo )
|
||||
main.mov( :r1 , :r7 )
|
||||
putint = @object_space.get_or_create_class(:Object).get_or_create_function(:putint)
|
||||
|
Reference in New Issue
Block a user