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    $0xfeb131978,%rax	# value to store
13
14	# test back-to-back rep/stosb's
15
16	mov	$1024,%rcx
17	mov	$buffer1, %rdi		# 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    %rcx,%rcx
26	mov    $buffer1, %rdi		# set destination
27	rep    stosb	  		# should not load at all
28
29	# test rep inside of a loop
30
31	mov    $1024, %rbx
32rep_loop:
33
34	mov    $1024,%rcx
35	mov    $buffer1, %rdi		# set destination
36	rep    stosb
37
38	mov    $1024,%rcx
39	mov    $buffer1, %rdi		# set destination
40	rep    stosb
41
42	dec    %rbx
43	jnz    rep_loop
44
45
46	#================================
47	# Exit
48	#================================
49exit:
50     	mov	$60,%rax
51	xor     %rdi,%rdi		# we return 0
52	syscall             		# and exit
53
54
55.bss
56
57.lcomm	buffer1,	16384
58
59