Debian Codegraph @

check/public-tests/instructions_n_t.c

raw
1 /*
2 * FCML - Free Code Manipulation Library.
3 * Copyright (C) 2010-2020 Slawomir Wojtasiak
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include <fcml_assembler.h>
21 #include "instructions_n_t.h"
22 #include "instructions_base_t.h"
23
24 fcml_bool fcml_tf_instructions_n_suite_init(void) {
25 return FCML_TRUE;
26 }
27
28 fcml_bool fcml_tf_instructions_n_suite_cleanup(void) {
29 return FCML_TRUE;
30 }
31
32 void fcml_tf_instruction_NEG(void) {
33
34 FCML_I32( "lock neg byte ptr [eax]", 0xF0, 0xF6, 0x18 );
35 FCML_I32( "xacquire lock neg byte ptr [eax]", 0xF2, 0xF0, 0xF6, 0x18 );
36 FCML_I32( "xrelease lock neg byte ptr [eax]", 0xF3, 0xF0, 0xF6, 0x18 );
37 FCML_I64_D( "neg byte ptr [rax]", 0x48, 0xF6, 0x18);
38 FCML_I64( "neg byte ptr [rax]", 0xF6, 0x18);
39
40 FCML_I32( "lock neg word ptr [eax]", 0xF0, 0x66, 0xF7, 0x18 );
41 FCML_I32( "xacquire lock neg word ptr [eax]", 0xF2, 0xF0, 0x66, 0xF7, 0x18 );
42 FCML_I32( "xrelease lock neg word ptr [eax]", 0xF3, 0xF0, 0x66, 0xF7, 0x18 );
43 FCML_I32( "neg dword ptr [eax]", 0xF7, 0x18 );
44 FCML_I64( "neg qword ptr [rax]", 0x48, 0xF7, 0x18 );
45
46 FCML_A64( "lock negb (%rax)", 0xf0, 0xf6, 0x18 );
47 FCML_A64( "xacquire lock negb (%rax)", 0xf2, 0xf0, 0xf6, 0x18 );
48 FCML_A64( "lock negw (%rax)", 0xf0, 0x66, 0xf7, 0x18 );
49 FCML_A64( "negl (%rax)", 0xf7, 0x18 );
50 FCML_A64( "negq (%rax)", 0x48, 0xf7, 0x18 );
51 }
52
53 void fcml_tf_instruction_NOP(void) {
54
55 FCML_I32( "nop", 0x90 );
56 FCML_I64( "nop", 0x90 );
57
58 FCML_I32( "nop word ptr [eax]", 0x66, 0x0f, 0x1f, 0x00 );
59 FCML_I32( "nop dword ptr [eax]", 0x0f, 0x1f, 0x00 );
60 FCML_I64( "nop qword ptr [rax]", 0x48, 0x0f, 0x1f, 0x00 );
61
62 FCML_A64( "nop", 0x90 );
63 FCML_A64( "nopw (%rax)", 0x66, 0x0f, 0x1f, 0x00 );
64 FCML_A64( "nopl (%rax)", 0x0f, 0x1f, 0x00 );
65 FCML_A64( "nop %eax", 0x0f, 0x1f, 0xc0 );
66 FCML_A64( "nopq (%rax)", 0x48, 0x0f, 0x1f, 0x00 );
67 FCML_A64( "add %cl,(%rdi)", 0x00, 0x0f );
68 }
69
70 void fcml_tf_instruction_NOT(void) {
71
72 FCML_I32( "lock not byte ptr [eax]", 0xF0, 0xF6, 0x10 );
73 FCML_I32( "xacquire lock not byte ptr [eax]", 0xF2, 0xF0, 0xF6, 0x10 );
74 FCML_I32( "xrelease lock not byte ptr [eax]", 0xF3, 0xF0, 0xF6, 0x10 );
75 FCML_I64_D( "not byte ptr [rax]", 0x48, 0xF6, 0x10 );
76 FCML_I64( "not byte ptr [rax]", 0xF6, 0x10 );
77
78 FCML_I32( "lock not word ptr [eax]", 0xF0, 0x66, 0xF7, 0x10 );
79 FCML_I32( "xacquire lock not word ptr [eax]", 0xF2, 0xF0, 0x66, 0xF7, 0x10 );
80 FCML_I32( "xrelease lock not word ptr [eax]", 0xF3, 0xF0, 0x66, 0xF7, 0x10 );
81 FCML_I32( "not dword ptr [eax]", 0xF7, 0x10 );
82 FCML_I64( "not qword ptr [rax]", 0x48, 0xF7, 0x10 );
83
84 FCML_A64( "lock notb (%rax)", 0xf0, 0xf6, 0x10 );
85 FCML_A64( "notb (%rax)", 0xf6, 0x10 );
86 FCML_A64( "lock notw (%rax)", 0xf0, 0x66, 0xf7, 0x10 );
87 FCML_A64( "xacquire lock notw (%rax)", 0xf2, 0xf0, 0x66, 0xf7, 0x10 );
88 FCML_A64( "notl (%rax)", 0xf7, 0x10 );
89 FCML_A64( "notq (%rax)", 0x48, 0xf7, 0x10 );
90 FCML_A64( "not %eax", 0xf7, 0xd0 );
91 FCML_A64_A( "notl %eax", 0xf7, 0xd0 );
92 }
93
94 fcml_stf_test_case fctl_ti_instructions_n[] = {
95 { "fcml_tf_instruction_NEG", fcml_tf_instruction_NEG },
96 { "fcml_tf_instruction_NOP", fcml_tf_instruction_NOP },
97 { "fcml_tf_instruction_NOT", fcml_tf_instruction_NOT },
98 FCML_STF_NULL_TEST
99 };
100
101 fcml_stf_test_suite fctl_si_instructions_n = {
102 "suite-fctl_ti_instructions_n", fcml_tf_instructions_n_suite_init, fcml_tf_instructions_n_suite_cleanup, fctl_ti_instructions_n
103 };
104