tls.ssa (1294B)
1 thread data $i = align 4 {w 42} 2 data $fmti = align 1 {b "i%d==%d\n", b 0} 3 4 thread data $x = {w 1, w 2, w 3, w 4} 5 data $fmtx = align 1 {b "*(x+%d)==%d\n", b 0} 6 7 export 8 function w $main() { 9 @start 10 %pthr =l alloc8 8 11 %rval =l alloc8 8 12 call $pthread_create(l %pthr, l 0, l $thread, l 0) 13 %t =l load %pthr 14 call $pthread_join(l %t, l %rval) 15 %i0 =w loadw thread $i 16 call $printf(l $fmti, ..., w 0, w %i0) 17 %i1 =w load %rval 18 call $printf(l $fmti, ..., w 1, w %i1) 19 20 %a0 =l call $xaddr() 21 %x0 =w load %a0 22 call $printf(l $fmtx, ..., w 0, w %x0) 23 %a4 =l call $xaddroff4() 24 %x4 =w load %a4 25 call $printf(l $fmtx, ..., w 4, w %x4) 26 %a8 =l call $xaddroff(l 8) 27 %x8 =w load %a8 28 call $printf(l $fmtx, ..., w 8, w %x8) 29 %xc =l call $xvalcnt(l 3) 30 call $printf(l $fmtx, ..., w 12, w %xc) 31 ret 0 32 } 33 34 function l $thread(l %arg) { 35 @start 36 %i3 =l add thread $i, 3 37 storeb 24, %i3 38 %ret =l loadsw thread $i 39 ret %ret 40 } 41 42 function l $xaddr() { 43 @start 44 ret thread $x 45 } 46 47 function l $xaddroff4() { 48 @start 49 %a =l add 4, thread $x 50 ret %a 51 } 52 53 function l $xaddroff(l %off) { 54 @start 55 %a =l add thread $x, %off 56 ret %a 57 } 58 59 function w $xvalcnt(l %cnt) { 60 @start 61 %o =l mul 4, %cnt 62 %a =l add thread $x, %o 63 %x =w load %a 64 ret %x 65 } 66 67 # >>> output 68 # i0==42 69 # i1==402653226 70 # *(x+0)==1 71 # *(x+4)==2 72 # *(x+8)==3 73 # *(x+12)==4 74 # <<<