2 # rep, repe (repz) and repne (repnz) prefixed string instructions
3 # only count as one instruction, even though they repeat many times
4 # This test makes sure the bbv plugin counts these instructions properly
5 # The answer is validated to hw perf counters.
10 cld # we want these to happen forward
12 #===================================
13 # Check varied order of the size prefix
14 # with the rep prefix. Older binutils
15 # did this one way, newer binutils the other
16 #===================================
22 mov $buffer1, %esi # set source
23 .byte 0x66, 0xf3, 0xad # lodsw
26 mov $buffer1, %esi # set source
27 .byte 0xf3, 0x66, 0xad # lodsw
32 #===================================
33 # Load and Store Instructions
34 #===================================
37 mov $0xd, %al # set eax to d
42 mov $buffer1, %edi # set destination
43 rep stosb # store d 16384 times, auto-increment
48 mov $buffer1, %esi # set source
49 rep lodsb # load byte 16384 times, auto-increment
51 cmp $0xd,%al # if we loaded wrong value
52 jne print_error # print an error
56 mov $0x020d,%ax # store 0x020d
59 mov $buffer1, %edi # set destination
60 rep stosw # store 8192 times, auto-increment
65 mov $buffer1, %esi # set source
66 rep lodsw # load 8192 times, auto-increment
68 cmp $0x020d,%ax # if we loaded wrong value
69 jne print_error # print an error
73 mov $0x0feb1378,%eax # store 0x0feb1378
76 mov $buffer1, %edi # set destination
77 rep stosl # store 4096 times, auto-increment
82 mov $buffer1, %esi # set source
83 rep lodsl # load 4096 times, auto-increment
85 cmp $0x0feb1378,%eax # if we loaded wrong value
86 jne print_error # print an error
88 #=============================
90 #=============================
113 #==================================
114 # Compare equal instructions
115 #==================================
117 # first set up the areas to compare
153 #==================================
154 # Compare not equal instructions
155 #==================================
157 # change second buffer
188 #====================================
189 # Check scan equal instruction
190 #====================================
216 #====================================
217 # Check scan not-equal instruction
218 #====================================
244 jmp exit # no error, skip to exit
248 mov $4, %eax # Write syscall
249 #if defined(VGO_darwin) || defined(VGO_freebsd)
254 #elif defined(VGO_linux)
255 mov $1, %ebx # print to stdout
256 mov $error_string, %ecx # string to print
257 mov $16, %edx # strlen
259 #elif defined(VGO_solaris)
268 #================================
270 #================================
273 inc %eax # put exit syscall number (1) in eax
274 #if defined(VGO_darwin) || defined(VGO_freebsd)
275 pushl $0 # we return 0
277 #elif defined(VGO_linux)
278 xor %ebx,%ebx # we return 0
280 #elif defined(VGO_solaris)
281 pushl $0 # we return 0
289 error_string: .ascii "Error detected!\n\0"
293 .lcomm buffer1, 16384
294 .lcomm buffer2, 16384