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
13 #===============================================
14 # Some SSE2 instructions start with 0xf2 or 0xf3
15 # Check for them, to make sure our rep detection
16 # handles things properly.
17 # We should check this on x86 too, but then we'd
18 # have to check for SSE2 capability somehow?
19 #===================================
27 #===================================
28 # Check varied order of the size prefix
29 # with the rep prefix. Older binutils
30 # did this one way, newer binutils the other
31 #===================================
37 mov $buffer1, %rsi # set source
38 .byte 0x66, 0xf3, 0xad # lodsw
41 mov $buffer1, %rsi # set source
42 .byte 0xf3, 0x66, 0xad # lodsw
47 #===================================
48 # Load and Store Instructions
49 #===================================
52 mov $0xd, %al # set eax to d
57 mov $buffer1, %rdi # set destination
58 rep stosb # store d 16384 times, auto-increment
63 mov $buffer1, %rsi # set source
64 rep lodsb # load byte 16384 times, auto-increment
66 cmp $0xd,%al # if we loaded wrong value
67 jne print_error # print an error
71 mov $0x020d,%ax # store 0x020d
74 mov $buffer1, %rdi # set destination
75 rep stosw # store 8192 times, auto-increment
80 mov $buffer1, %rsi # set source
81 rep lodsw # load 8192 times, auto-increment
83 cmp $0x020d,%ax # if we loaded wrong value
84 jne print_error # print an error
88 mov $0x0feb1378,%eax # store 0x0feb1378
91 mov $buffer1, %rdi # set destination
92 rep stosl # store 4096 times, auto-increment
97 mov $buffer1, %rsi # set source
98 rep lodsl # load 4096 times, auto-increment
100 cmp $0x0feb1378,%eax # if we loaded wrong value
101 jne print_error # print an error
105 mov $0xfeb131978a5a5a5a,%rax
108 mov $buffer1, %rdi # set destination
109 rep stosq # store 2048 times, auto-increment
114 mov $buffer1, %rsi # set source
115 rep lodsq # load 2048 times, auto-increment
118 # !if we loaded wrong value
119 jne print_error # print an error
122 #=============================
124 #=============================
155 #==================================
156 # Compare equal instructions
157 #==================================
159 # first set up the areas to compare
206 #==================================
207 # Compare not equal instructions
208 #==================================
210 # change second buffer
222 # repne cmpsb FIXME! Not implemented valgrind
230 # repne cmpsw FIXME! Not implemented valgrind
238 # repne cmpsl FIXME! Not implemented valgrind
246 # repne cmpsq FIXME! Not implemented valgrind
249 #====================================
250 # Check scan equal instruction
251 #====================================
279 mov $0xa5a5a5a5a5a5a5a5,%rax
286 #====================================
287 # Check scan not-equal instruction
288 #====================================
316 mov $0xa5a5a5a5a5a5a5a5,%rax
322 jmp exit # no error, skip to exit
326 mov $1, %rax # Write syscall
327 mov $1, %rdi # print to stdout
328 mov $error_string, %rsi # string to print
329 mov $16, %edx # strlen
330 syscall # call syscall
332 #================================
334 #================================
337 xor %rdi,%rdi # we return 0
342 error_string: .asciz "Error detected!\n"
346 .lcomm buffer1, 16384
347 .lcomm buffer2, 16384