Home | History | Annotate | Download | only in x86
      1 # When trying (and failing) to instrument at the basic block level
      2 # I thought up a lot of corner-cases in the rep code.  This tries
      3 # to catch some of them
      4 
      5 # Performance counters give us 8207 insns
      6 #    11 + 8*1024 + 3 = 8206
      7 
      8 	.globl _start
      9 _start:
     10 	cld				# we want these to happen forward
     11 
     12 	mov    $0xfeb1378,%eax		# value to store
     13 
     14 	# test back-to-back rep/stosb's
     15 
     16 	mov	$1024,%ecx
     17 	mov	$buffer1, %edi		# set destination
     18 	rep	stosb	    		# store 1024 times
     19 	rep	stosb	    		# should store 0 times
     20 	rep	stosb			# should store 0 times
     21 
     22 
     23 	# test stosb where cx is 0
     24 
     25 	xor    %ecx,%ecx
     26 	mov    $buffer1, %edi		# set destination
     27 	rep    stosb	  		# should not load at all
     28 
     29 	# test rep inside of a loop
     30 
     31 	mov    $1024, %ebx
     32 rep_loop:
     33 
     34 	mov    $1024,%ecx
     35 	mov    $buffer1, %edi		# set destination
     36 	rep    stosb
     37 
     38 	mov    $1024,%ecx
     39 	mov    $buffer1, %edi		# set destination
     40 	rep    stosb
     41 
     42 	dec    %ebx
     43 	jnz    rep_loop
     44 
     45 
     46 	#================================
     47 	# Exit
     48 	#================================
     49 exit:
     50      	mov	$1,%eax
     51 #if defined(VGO_darwin)
     52 	pushl   $0			# we return 0
     53 	int     $0x80          		# and exit
     54 #elif defined(VGO_linux)
     55 	xor     %ebx,%ebx		# we return 0
     56 	int	$0x80          		# and exit
     57 #elif defined(VGO_solaris)
     58 	pushl   $0			# we return 0
     59 	int     $0x91          		# and exit
     60 #else
     61 #  error "Unknown OS"
     62 #endif
     63 
     64 
     65 #.bss
     66 
     67 .lcomm	buffer1,	16384
     68 
     69