dark.ssa (633B)
1 # skip arm64 arm64_apple rv64 2 # a hack example, 3 # we use a dark type to get 4 # a pointer to the stack. 5 6 type :magic = align 1 { 0 } 7 8 data $ret = { l 0 } 9 10 export 11 function $test(:magic %p) { 12 @start 13 %av =w loadw $a 14 %a1 =w add 1, %av 15 storew %a1, $a # increment $a 16 %r1 =l loadl $ret # fetch from $ret 17 %p1 =l add %p, -8 18 %r2 =l loadl %p1 # get the return address 19 storel %r2, $ret # store it in $ret 20 %c =w ceql %r1, %r2 21 jnz %c, @fin, @cal 22 @cal 23 %i =w call $test() # no argument given, intentionally! 24 @fin 25 ret 26 } 27 28 # >>> driver 29 # extern void test(void); 30 # int a = 2; 31 # int main() { test(); return !(a == 5); } 32 # <<<