xref: /qemu/tests/tcg/x86_64/system/patch-target.c (revision 71d337943870b30ed8a137fb14dbf4680ba9ccc7)
1 /*
2  * SPDX-License-Identifier: GPL-2.0-or-later
3  *
4  * This test target increments a value 100 times. The patcher converts the
5  * inc instruction to a nop, so it only increments the value once.
6  *
7  */
8 #include <minilib.h>
9 
10 int main(void)
11 {
12     ml_printf("Running test...\n");
13     unsigned int x = 0;
14     for (int i = 0; i < 100; i++) {
15         asm volatile (
16             "inc %[x]"
17             : [x] "+a" (x)
18         );
19     }
20     ml_printf("Value: %d\n", x);
21     return 0;
22 }
23