Debian Codegraph @

check/public-tests/instructions_t_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_t_t.h"
22 #include "instructions_base_t.h"
23
24 fcml_bool fcml_tf_instructions_t_suite_init(void) {
25 return FCML_TRUE;
26 }
27
28 fcml_bool fcml_tf_instructions_t_suite_cleanup(void) {
29 return FCML_TRUE;
30 }
31
32 void fcml_tf_instruction_TEST(void) {
33
34 FCML_I32_M( "test al,20h", 2, FCML_MI( 0xf6, 0xc0, 0x20 ), FCML_MI( 0xa8, 0x20 ) );
35 FCML_I64_M( "test al,20h", 2, FCML_MI( 0xf6, 0xc0, 0x20 ), FCML_MI( 0xa8, 0x20 ) );
36
37 FCML_A64( "testb $0x20,%al", 0xf6, 0xc0, 0x20 );
38
39 FCML_I32_M( "test eax,00104020h", 2, FCML_MI( 0xf7, 0xc0, 0x20, 0x40, 0x10, 0x00 ), FCML_MI( 0xa9, 0x20, 0x40, 0x10, 0x00 ) );
40 FCML_I32_M( "test ax,0020h", 2, FCML_MI( 0x66, 0xf7, 0xc0, 0x20, 0x00 ), FCML_MI( 0x66, 0xa9, 0x20, 0x00 ) );
41
42 FCML_A64_M( "test $0x0000000000104020,%rax", 2, FCML_MI( 0x48, 0xf7, 0xc0, 0x20, 0x40, 0x10, 0x00 ), FCML_MI( 0x48, 0xa9, 0x20, 0x40, 0x10, 0x00 ) );
43 FCML_A64_M( "test $0x4020,%ax", 2, FCML_MI( 0x66, 0xf7, 0xc0, 0x20, 0x40 ), FCML_MI( 0x66, 0xa9, 0x20, 0x40 ) );
44 FCML_A64_M( "test $0x00104020,%eax", 2, FCML_MI( 0xf7, 0xc0, 0x20, 0x40, 0x10, 0x00 ), FCML_MI( 0xa9, 0x20, 0x40, 0x10, 0x00 ) );
45
46 FCML_I64_M( "test rax,0ffffffffff104020h", 2, FCML_MI( 0x48, 0xf7, 0xc0, 0x20, 0x40, 0x10, 0xff ), FCML_MI( 0x48, 0xa9, 0x20, 0x40, 0x10, 0xff ) );
47
48 FCML_I32( "test byte ptr [eax],0ffh", 0xF6, 0x00, 0xFF );
49 FCML_I64_D( "test byte ptr [rax],0ffh", 0x48, 0xF6, 0x00, 0xFF );
50
51 FCML_A64( "testb $0xff,(%rax)", 0xf6, 0x00, 0xff );
52
53 FCML_I32( "test dword ptr [eax],0ff001040h", 0xF7, 0x00, 0x40, 0x10, 0x00, 0xFF );
54 FCML_I32( "test word ptr [eax],0ff00h", 0x66, 0xF7, 0x00, 0x00, 0xff );
55
56 FCML_A64( "testl $0xff001040,(%rax)", 0xf7, 0x00, 0x40, 0x10, 0x00, 0xff );
57 FCML_A64( "testw $0x1040,(%rax)", 0x66, 0xf7, 0x00, 0x40, 0x10 );
58
59 FCML_A64( "testq $0x0000000000001040,(%rax)", 0x48, 0xf7, 0x00, 0x40, 0x10, 0x00, 0x00 );
60
61 FCML_I64( "test qword ptr [rax],0000000011ff1040h", 0x48, 0xF7, 0x00, 0x40, 0x10, 0xFF, 0x11 );
62
63 FCML_I32( "test byte ptr [eax],al", 0x84, 0x00 );
64 FCML_I64_D( "test byte ptr [rax],al", 0x48, 0x84, 0x00 );
65
66 FCML_I32( "test word ptr [eax],ax", 0x66, 0x85, 0x00 );
67 FCML_I64( "test qword ptr [rax],rax", 0x48, 0x85, 0x00 );
68 }
69
70 void fcml_tf_instruction_TZCNT(void) {
71
72 FCML_I32( "tzcnt eax,dword ptr [eax]", 0xF3, 0x0F, 0xBC, 0x00 );
73 FCML_I32( "tzcnt ax,word ptr [eax]", 0x66, 0xF3, 0x0F, 0xBC, 0x00 );
74 FCML_I32( "tzcnt ax,ax", 0x66, 0xF3, 0x0F, 0xBC, 0xC0 );
75 FCML_I64( "tzcnt rax,qword ptr [rax]", 0xF3, 0x48, 0x0F, 0xBC, 0x00 );
76
77 FCML_A64( "tzcnt (%rax),%eax", 0xf3, 0x0f, 0xbc, 0x00 );
78 FCML_A64( "tzcnt (%rax),%ax", 0x66, 0xf3, 0x0f, 0xbc, 0x00 );
79 FCML_A64( "tzcnt %ax,%ax", 0x66, 0xf3, 0x0f, 0xbc, 0xc0 );
80 FCML_A64( "tzcnt (%rax),%rax", 0xf3, 0x48, 0x0f, 0xbc, 0x00 );
81 }
82
83 void fcml_tf_instruction_TZMSK(void) {
84
85 FCML_I32( "tzmsk ebx,dword ptr [eax]", 0x8F, 0xE9, 0x60, 0x01, 0x20 );
86 FCML_I32( "tzmsk ebx,eax", 0x8F, 0xE9, 0x60, 0x01, 0xE0 );
87
88 FCML_I64( "tzmsk rbx,qword ptr [rax]", 0x8F, 0xE9, 0xE0, 0x01, 0x20 );
89 FCML_I64( "tzmsk rbx,rax", 0x8F, 0xE9, 0xE0, 0x01, 0xE0 );
90
91 FCML_A64( "tzmsk (%rax),%ebx", 0x8f, 0xe9, 0x60, 0x01, 0x20 );
92 FCML_A64( "tzmsk %eax,%ebx", 0x8f, 0xe9, 0x60, 0x01, 0xe0 );
93 FCML_A64( "tzmsk (%rax),%rbx", 0x8f, 0xe9, 0xe0, 0x01, 0x20 );
94 FCML_A64( "tzmsk %rax,%rbx", 0x8f, 0xe9, 0xe0, 0x01, 0xe0 );
95 }
96
97 void fcml_tf_instruction_T1MSKC(void) {
98
99 FCML_I32( "t1mskc ebx,dword ptr [eax]", 0x8F, 0xE9, 0x60, 0x01, 0x38 );
100 FCML_I32( "t1mskc ebx,eax", 0x8F, 0xE9, 0x60, 0x01, 0xF8 );
101
102 FCML_I64( "t1mskc rbx,qword ptr [rax]", 0x8F, 0xE9, 0xE0, 0x01, 0x38 );
103 FCML_I64( "t1mskc rbx,rax", 0x8F, 0xE9, 0xE0, 0x01, 0xF8 );
104
105 FCML_A64( "t1mskc (%rax),%ebx", 0x8f, 0xe9, 0x60, 0x01, 0x38 );
106 FCML_A64( "t1mskc %eax,%ebx", 0x8f, 0xe9, 0x60, 0x01, 0xf8 );
107 FCML_A64( "t1mskc (%rax),%rbx", 0x8f, 0xe9, 0xe0, 0x01, 0x38 );
108 FCML_A64( "t1mskc %rax,%rbx", 0x8f, 0xe9, 0xe0, 0x01, 0xf8 );
109 }
110
111 fcml_stf_test_case fctl_ti_instructions_t[] = {
112 { "fcml_tf_instruction_TEST", fcml_tf_instruction_TEST },
113 { "fcml_tf_instruction_TZCNT", fcml_tf_instruction_TZCNT },
114 { "fcml_tf_instruction_TZMSK", fcml_tf_instruction_TZMSK },
115 { "fcml_tf_instruction_T1MSKC", fcml_tf_instruction_T1MSKC },
116 FCML_STF_NULL_TEST
117 };
118
119 fcml_stf_test_suite fctl_si_instructions_t = {
120 "suite-fctl_ti_instructions_t", fcml_tf_instructions_t_suite_init, fcml_tf_instructions_t_suite_cleanup, fctl_ti_instructions_t
121 };
122