3 .type __clone, %function
5 # int clone(fn, stack, flags, arg, ptid, tls, ctid)
9 # tid = syscall(SYS_clone,c,b,e,f,g);
10 # if (!tid) syscall(SYS_exit, a(d));
13 # create initial stack frame for new thread
18 # save fn and arg to child stack
22 # shuffle args into correct registers and call SYS_clone
28 li 0, 120 # SYS_clone = 120
31 # if error, negate return (errno)
35 1: # if we're the parent, return
39 # we're the child. call fn(arg)
45 # call SYS_exit. exit code is already in r3 from fn return value
46 li 0, 1 # SYS_exit = 1