added save-locals and restore-locals, implemented on ARM
[voodoo-lang.git] / test / shift.voo
blob6656b99c96fe2845cb013ed5a75fac8b0fa38208
1 #### Test shift actions
3 section data
5 align
6 equal:
7 string "equal\n\x00"
9 align
10 format_shl_13_7:
11 string "shl 13 7: %d\n\x00"
13 align
14 format_shl_150_6:
15 string "shl 150 6: %d\n\x00"
17 align
18 format_asr_150_4:
19 string "asr 150 4: %d\n\x00"
21 align
22 format_asr_170_2:
23 string "asr 170 2: %d\n\x00"
25 align
26 format_asr_m150_4:
27 string "asr -150 4: %d\n\x00"
29 align
30 format_bsr_m150_4_positive:
31 string "bsr -150 4: positive\n\x00"
33 align
34 format_bsr_m150_4_negative:
35 string "bsr -150 4: negative\n\x00"
37 align
38 format_asr_m85_3:
39 string "asr -85 3: %d\n\x00"
41 align
42 format_bsr_m85_3_positive:
43 string "bsr -85 3: positive\n\x00"
45 align
46 format_bsr_m85_3_negative:
47 string "bsr -85 3: negative\n\x00"
49 align
50 not_equal:
51 string "not equal %d != %d != %d\n\x00"
56 section functions
57 import printf
58 export main
60 align
61 main:
62 function argc argv
63     let x asr 150 4
64     call printf format_asr_150_4 x
66     set x 170
67     set x asr x 2
68     call printf format_asr_170_2 x
70     let y asr -150 4
71     call printf format_asr_m150_4 y
73     let z bsr -150 4
74     iflt z 0
75         call printf format_bsr_m150_4_negative
76     else
77         call printf format_bsr_m150_4_positive
78     end if
80     set x shr -150 4
81     ifeq x y
82         call printf equal
83     else
84         ifeq x z
85             call printf equal
86         else
87             call printf not_equal x y z
88         end if
89     end if
91     set y -85
92     set y asr y 3
93     call printf format_asr_m85_3 y
95     set z -85
96     set z bsr z 3
97     iflt z 0
98         call printf format_bsr_m85_3_negative
99     else
100         call printf format_bsr_m85_3_positive
101     end if
103     set x -85
104     set x shr x 3
105     ifeq x y
106         call printf equal
107     else
108         ifeq x z
109             call printf equal
110         else
111             call printf not_equal x y z
112         end if
113     end if
115     set x shl 13 7
116     call printf format_shl_13_7 x
118     set x 150
119     set x shl x 6
120     call printf format_shl_150_6 x
122     return 0
123 end function