Removed superfluous debug comments from ARM generator
[voodoo-lang.git] / test / auto-bytes.voo
blob5ad57cce5c6e8f5957d8bd06f9558788a6d02338
1 #### Test program for auto-bytes
3 section data
5 print_endline_fmt:
6 string "%s\n\x00"
8 print_int_fmt:
9 string "%d\n\x00"
11 section functions
12 export main
13 import printf
15 align
16 test:
17 function
18     let nbytes 17
19     let max sub nbytes 1
20     let bytes auto-bytes nbytes
21     let i 0
22     let j 97
23 test_loop:
24     iflt i max
25         set-byte bytes i j
26         set i add i 1
27         set j add j 1
28         goto test_loop
29     end if
30     set-byte bytes max 0
31     call printf print_endline_fmt bytes
32     call test_pass bytes
34     block
35         let a 42
36         let more-bytes auto-bytes 19
37         let b 0
38         let c 72
39 test_loop1:
40         iflt b 18
41             set-byte more-bytes b c
42             set b add b 1
43             set c add c 1
44             goto test_loop1
45         end if
46         set-byte more-bytes 18 0
47         call printf print_endline_fmt more-bytes
48         call printf print_int_fmt a
49         call printf print_int_fmt b
50         call printf print_int_fmt c
51     end block
53     call printf print_int_fmt i
54     call printf print_int_fmt j
55     call printf print_endline_fmt bytes
57     # Allocate memory in a block inside a loop. The memory
58     # should be freed on each iteration, so this should not
59     # run out of memory.
60     set i 0
61 test_loop2:
62     iflt i 262144
63         block
64             set bytes auto-bytes 16384
65         end block
66         set i add i 1
67         goto test_loop2
68     end if
70     return 0
71 end function
73 align
74 test_pass:
75 function text
76     call printf print_endline_fmt text
77     let bytes auto-bytes 4
78     set-byte bytes 0 48
79     set-byte bytes 1 49
80     set-byte bytes 2 50
81     set-byte bytes 3 0
82     call printf print_endline_fmt bytes
83     return 0
84 end function
86 align
87 main:
88 function argc argv
89     call test
90     return 0
91 end function