! compile with ! as -xarch=v8plusa -o falign_test.o falign_test.s ; ! ld -o falign_test falign_test.o ! + Syscalls have number in %g1, options in %o0,%o1,... ! Result returned in %o0 ! Linux syscall is called by "ta 0x10" .equ SYSCALL_EXIT,1 .equ SYSCALL_WRITE,4 .equ STDOUT,1 .globl _start _start: ! ! print the source! ! set source,%o1 call write_stdout nop ! ! copy the string ! set source,%o1 set destination,%o0 alignaddr %o1, %g0, %o3 membar #StoreStore|#LoadStore|#StoreLoad wr %g0, 0xf0, %asi ! set block-copy asi nop ldda [ %o1 ] %asi, %f0 nop faligndata %f0, %f2, %f16 faligndata %f2, %f4, %f18 faligndata %f4, %f6, %f20 faligndata %f6, %f8, %f22 faligndata %f8, %f10, %f24 faligndata %f10, %f12, %f26 faligndata %f12, %f14, %f28 faligndata %f14, %f16, %f30 after: stda %f16, [ %o0 ] %asi nop nop ! ! print the copy ! set destination,%o1 call write_stdout nop ba exit nop #================================ # WRITE_STDOUT #================================ # %o1 has string write_stdout: set SYSCALL_WRITE,%g1 ! Write syscall in %g1 set STDOUT,%o0 ! 1 in %o0 (stdout) set 0,%o2 ! 0 (count) in %o2 str_loop1: ldub [%o1+%o2],%l0 ! load byte cmp %l0,%g0 ! compare against zero bnz str_loop1 ! if not nul, repeat # BRANCH DELAY SLOT inc %o2 ! increment count dec %o2 ! correct count ta 0x10 ! run the syscall retl ! return nop exit: mov 0,%o0 ! exit value mov SYSCALL_EXIT,%g1 ! put the exit syscall number in g1 ta 0x10 ! and exit !=========================================================================== .data !=========================================================================== .balign 64 !(needs to be on 64-byte boundary) ! 1 2 3 4 ! 0123456789012345678901234567890123456789012345678 source: .ascii "The quick brown fox jumped over " .ascii "the lazy dog! Need more fill!\n\0" .lcomm destination,64