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
32rep_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	#================================
49exit:
50     	mov	$1,%eax
51#ifdef VGO_darwin
52	pushl	$0
53#else
54	xor     %ebx,%ebx		# we return 0
55#endif
56	int	$0x80          		# and exit
57
58
59#.bss
60
61.lcomm	buffer1,	16384
62
63