| 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 "intel_parser_t.h" |
| 21 |
|
| 22 |
#include <string.h> |
| 23 |
|
| 24 |
#include <fcml_ceh.h> |
| 25 |
#include <fcml_common.h> |
| 26 |
#include <fcml_types.h> |
| 27 |
#include <fcml_errors.h> |
| 28 |
#include <fcml_parser.h> |
| 29 |
#include <fcml_parser_int.h> |
| 30 |
#include <fcml_intel_dialect.h> |
| 31 |
|
| 32 |
fcml_st_dialect *internal_dialect_intel = NULL; |
| 33 |
fcml_st_parser_context internal_intel_context = {0}; |
| 34 |
|
| 35 |
fcml_bool fcml_tf_parser_suite_init(void) { |
| 36 |
fcml_fn_dialect_init_intel( FCML_INTEL_DIALECT_CF_DEFAULT, &internal_dialect_intel ); |
| 37 |
internal_intel_context.dialect = internal_dialect_intel; |
| 38 |
return internal_dialect_intel != NULL; |
| 39 |
} |
| 40 |
|
| 41 |
fcml_bool fcml_tf_parser_suite_cleanup(void) { |
| 42 |
if( internal_dialect_intel ) { |
| 43 |
fcml_fn_dialect_free( internal_dialect_intel ); |
| 44 |
} |
| 45 |
fcml_fn_symbol_table_free( internal_intel_context.symbol_table ); |
| 46 |
return FCML_TRUE; |
| 47 |
} |
| 48 |
|
| 49 |
void fcml_tf_parser_int_parse_test1(void) { |
| 50 |
fcml_st_parser_result result; |
| 51 |
fcml_fn_parser_result_prepare( &result ); |
| 52 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 80-90", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 53 |
if( result.instruction != NULL ) { |
| 54 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 55 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 56 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_TRUE ); |
| 57 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, (fcml_int8_t)-10 ); |
| 58 |
} else { |
| 59 |
STF_FAIL(); |
| 60 |
} |
| 61 |
fcml_fn_parser_result_free( &result ); |
| 62 |
} |
| 63 |
|
| 64 |
void fcml_tf_parser_int_parse_test2(void) { |
| 65 |
fcml_st_parser_result result; |
| 66 |
fcml_fn_parser_result_prepare( &result ); |
| 67 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 0xFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 68 |
if( result.instruction != NULL ) { |
| 69 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 70 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 71 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 72 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, (fcml_int8_t)0xFF ); |
| 73 |
} else { |
| 74 |
STF_FAIL(); |
| 75 |
} |
| 76 |
fcml_fn_parser_result_free( &result ); |
| 77 |
} |
| 78 |
|
| 79 |
void fcml_tf_parser_int_parse_test3(void) { |
| 80 |
fcml_st_parser_result result; |
| 81 |
fcml_fn_parser_result_prepare( &result ); |
| 82 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 0xFFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 83 |
if( result.instruction != NULL ) { |
| 84 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 85 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_16 ); |
| 86 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 87 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int16, (fcml_uint16_t)0x0FFF ); |
| 88 |
} else { |
| 89 |
STF_FAIL(); |
| 90 |
} |
| 91 |
fcml_fn_parser_result_free( &result ); |
| 92 |
} |
| 93 |
|
| 94 |
void fcml_tf_parser_int_parse_test4(void) { |
| 95 |
fcml_st_parser_result result; |
| 96 |
fcml_fn_parser_result_prepare( &result ); |
| 97 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 0xFFFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 98 |
if( result.instruction != NULL ) { |
| 99 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 100 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_16 ); |
| 101 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 102 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int16, (fcml_int16_t)0xFFFF ); |
| 103 |
} else { |
| 104 |
STF_FAIL(); |
| 105 |
} |
| 106 |
fcml_fn_parser_result_free( &result ); |
| 107 |
} |
| 108 |
|
| 109 |
void fcml_tf_parser_int_parse_test5(void) { |
| 110 |
fcml_st_parser_result result; |
| 111 |
fcml_fn_parser_result_prepare( &result ); |
| 112 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 0xFFFFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 113 |
if( result.instruction != NULL ) { |
| 114 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 115 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_32 ); |
| 116 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 117 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int32, (fcml_uint32_t)0x000FFFFF ); |
| 118 |
} else { |
| 119 |
STF_FAIL(); |
| 120 |
} |
| 121 |
fcml_fn_parser_result_free( &result ); |
| 122 |
} |
| 123 |
|
| 124 |
void fcml_tf_parser_int_parse_test6(void) { |
| 125 |
fcml_st_parser_result result; |
| 126 |
fcml_fn_parser_result_prepare( &result ); |
| 127 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 0xFFFFFFFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 128 |
if( result.instruction != NULL ) { |
| 129 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 130 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_32 ); |
| 131 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 132 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int32, (fcml_uint32_t)0xFFFFFFFF ); |
| 133 |
} else { |
| 134 |
STF_FAIL(); |
| 135 |
} |
| 136 |
fcml_fn_parser_result_free( &result ); |
| 137 |
} |
| 138 |
|
| 139 |
void fcml_tf_parser_int_parse_test7(void) { |
| 140 |
fcml_st_parser_result result; |
| 141 |
fcml_fn_parser_result_prepare( &result ); |
| 142 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 0xFFFFFFFFFFFFFFFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 143 |
if( result.instruction != NULL ) { |
| 144 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 145 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_64 ); |
| 146 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 147 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int64, 0xFFFFFFFFFFFFFFFFUL ); |
| 148 |
} else { |
| 149 |
STF_FAIL(); |
| 150 |
} |
| 151 |
fcml_fn_parser_result_free( &result ); |
| 152 |
} |
| 153 |
|
| 154 |
void fcml_tf_parser_int_parse_test8(void) { |
| 155 |
fcml_st_parser_result result; |
| 156 |
fcml_fn_parser_result_prepare( &result ); |
| 157 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov -0xFFFFFFFFFFFFFFFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 158 |
if( result.instruction != NULL ) { |
| 159 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 160 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 161 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 162 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, (fcml_uint8_t)(fcml_int8_t)1 ); |
| 163 |
} else { |
| 164 |
STF_FAIL(); |
| 165 |
} |
| 166 |
fcml_fn_parser_result_free( &result ); |
| 167 |
} |
| 168 |
|
| 169 |
void fcml_tf_parser_int_parse_test9(void) { |
| 170 |
fcml_st_parser_result result; |
| 171 |
fcml_fn_parser_result_prepare( &result ); |
| 172 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov -0xFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 173 |
if( result.instruction != NULL ) { |
| 174 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 175 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_16 ); |
| 176 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_TRUE ); |
| 177 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int16, (fcml_int16_t)-255 ); |
| 178 |
} else { |
| 179 |
STF_FAIL(); |
| 180 |
} |
| 181 |
fcml_fn_parser_result_free( &result ); |
| 182 |
} |
| 183 |
|
| 184 |
void fcml_tf_parser_int_parse_test10(void) { |
| 185 |
fcml_st_parser_result result; |
| 186 |
fcml_fn_parser_result_prepare( &result ); |
| 187 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 1+2", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 188 |
if( result.instruction != NULL ) { |
| 189 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 190 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 191 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 192 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, (fcml_uint8_t)(fcml_int8_t)3 ); |
| 193 |
} else { |
| 194 |
STF_FAIL(); |
| 195 |
} |
| 196 |
fcml_fn_parser_result_free( &result ); |
| 197 |
} |
| 198 |
|
| 199 |
void fcml_tf_parser_int_parse_test11(void) { |
| 200 |
fcml_st_parser_result result; |
| 201 |
fcml_fn_parser_result_prepare( &result ); |
| 202 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 1+2*8/(15-13)-1", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 203 |
if( result.instruction != NULL ) { |
| 204 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 205 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 206 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 207 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, (fcml_uint8_t)8 ); |
| 208 |
} else { |
| 209 |
STF_FAIL(); |
| 210 |
} |
| 211 |
fcml_fn_parser_result_free( &result ); |
| 212 |
} |
| 213 |
|
| 214 |
void fcml_tf_parser_int_parse_test12(void) { |
| 215 |
fcml_st_parser_result result; |
| 216 |
fcml_fn_parser_result_prepare( &result ); |
| 217 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 65535", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 218 |
if( result.instruction != NULL ) { |
| 219 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 220 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_16 ); |
| 221 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 222 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int16, (fcml_int16_t)0xFFFF ); |
| 223 |
} else { |
| 224 |
STF_FAIL(); |
| 225 |
} |
| 226 |
fcml_fn_parser_result_free( &result ); |
| 227 |
} |
| 228 |
|
| 229 |
void fcml_tf_parser_int_parse_test13(void) { |
| 230 |
fcml_st_parser_result result; |
| 231 |
fcml_fn_parser_result_prepare( &result ); |
| 232 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov -32768", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 233 |
if( result.instruction != NULL ) { |
| 234 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 235 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_16 ); |
| 236 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_TRUE ); |
| 237 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int16, (fcml_int16_t)-32768 ); |
| 238 |
} else { |
| 239 |
STF_FAIL(); |
| 240 |
} |
| 241 |
fcml_fn_parser_result_free( &result ); |
| 242 |
} |
| 243 |
|
| 244 |
void fcml_tf_parser_int_parse_test14(void) { |
| 245 |
fcml_st_parser_result result; |
| 246 |
fcml_fn_parser_result_prepare( &result ); |
| 247 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov (-2147483647 - 1)", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 248 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 249 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_32 ); |
| 250 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_TRUE ); |
| 251 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int32, (fcml_uint32_t)(-2147483647 - 1) ); |
| 252 |
fcml_fn_parser_result_free( &result ); |
| 253 |
} |
| 254 |
|
| 255 |
void fcml_tf_parser_int_parse_test15(void) { |
| 256 |
fcml_st_parser_result result; |
| 257 |
fcml_fn_parser_result_prepare( &result ); |
| 258 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov (-9223372036854775807 - 1)", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 259 |
if( result.instruction != NULL ) { |
| 260 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 261 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_64 ); |
| 262 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_TRUE ); |
| 263 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int64, (fcml_uint64_t)(-9223372036854775807LL - 1) ); |
| 264 |
} else { |
| 265 |
STF_FAIL(); |
| 266 |
} |
| 267 |
fcml_fn_parser_result_free( &result ); |
| 268 |
} |
| 269 |
|
| 270 |
void fcml_tf_parser_int_parse_test16(void) { |
| 271 |
fcml_st_parser_result result; |
| 272 |
fcml_fn_parser_result_prepare( &result ); |
| 273 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 18446744073709551615", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 274 |
if( result.instruction != NULL ) { |
| 275 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 276 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_64 ); |
| 277 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 278 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int64, (fcml_uint64_t)18446744073709551615ULL ); |
| 279 |
} else { |
| 280 |
STF_FAIL(); |
| 281 |
} |
| 282 |
fcml_fn_parser_result_free( &result ); |
| 283 |
} |
| 284 |
|
| 285 |
void fcml_tf_parser_int_parse_test17(void) { |
| 286 |
fcml_st_parser_result result; |
| 287 |
fcml_fn_parser_result_prepare( &result ); |
| 288 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 5675", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 289 |
if( result.instruction != NULL ) { |
| 290 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 291 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_16 ); |
| 292 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 293 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int16, (fcml_uint16_t)5675 ); |
| 294 |
} else { |
| 295 |
STF_FAIL(); |
| 296 |
} |
| 297 |
fcml_fn_parser_result_free( &result ); |
| 298 |
} |
| 299 |
|
| 300 |
void fcml_tf_parser_int_parse_test18(void) { |
| 301 |
fcml_st_parser_result result; |
| 302 |
fcml_fn_parser_result_prepare( &result ); |
| 303 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 2147483647", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 304 |
if( result.instruction != NULL ) { |
| 305 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 306 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_32 ); |
| 307 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 308 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int32, (fcml_uint32_t)2147483647 ); |
| 309 |
} else { |
| 310 |
STF_FAIL(); |
| 311 |
} |
| 312 |
fcml_fn_parser_result_free( &result ); |
| 313 |
} |
| 314 |
|
| 315 |
void fcml_tf_parser_int_parse_test19(void) { |
| 316 |
fcml_st_parser_result result; |
| 317 |
fcml_fn_parser_result_prepare( &result ); |
| 318 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 4294967295", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 319 |
if( result.instruction != NULL ) { |
| 320 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 321 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_32 ); |
| 322 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 323 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int32, (fcml_uint32_t)4294967295U ); |
| 324 |
} else { |
| 325 |
STF_FAIL(); |
| 326 |
} |
| 327 |
fcml_fn_parser_result_free( &result ); |
| 328 |
} |
| 329 |
|
| 330 |
void fcml_tf_parser_int_parse_test20(void) { |
| 331 |
fcml_st_parser_result result; |
| 332 |
fcml_fn_parser_result_prepare( &result ); |
| 333 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 4294967296", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 334 |
if( result.instruction != NULL ) { |
| 335 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 336 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_64 ); |
| 337 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 338 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int64, (fcml_uint64_t)4294967296ULL ); |
| 339 |
} else { |
| 340 |
STF_FAIL(); |
| 341 |
} |
| 342 |
fcml_fn_parser_result_free( &result ); |
| 343 |
} |
| 344 |
|
| 345 |
void fcml_tf_parser_int_parse_test21(void) { |
| 346 |
fcml_st_parser_result result; |
| 347 |
fcml_fn_parser_result_prepare( &result ); |
| 348 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov -0xFFFFFFFF", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 349 |
if( result.instruction != NULL ) { |
| 350 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 351 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_64 ); |
| 352 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_TRUE ); |
| 353 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int64, (fcml_uint64_t)-4294967295LL ); |
| 354 |
} else { |
| 355 |
STF_FAIL(); |
| 356 |
} |
| 357 |
fcml_fn_parser_result_free( &result ); |
| 358 |
} |
| 359 |
|
| 360 |
void fcml_tf_parser_int_parse_test22(void) { |
| 361 |
fcml_st_parser_result result; |
| 362 |
fcml_fn_parser_result_prepare( &result ); |
| 363 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 255", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 364 |
if( result.instruction != NULL ) { |
| 365 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 366 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 367 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 368 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, (fcml_int8_t)0xFF ); |
| 369 |
} else { |
| 370 |
STF_FAIL(); |
| 371 |
} |
| 372 |
fcml_fn_parser_result_free( &result ); |
| 373 |
} |
| 374 |
|
| 375 |
void fcml_tf_parser_int_parse_test23(void) { |
| 376 |
fcml_st_parser_result result; |
| 377 |
fcml_fn_parser_result_prepare( &result ); |
| 378 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov 1", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 379 |
if( result.instruction != NULL ) { |
| 380 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 381 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 382 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 383 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, 1 ); |
| 384 |
} else { |
| 385 |
STF_FAIL(); |
| 386 |
} |
| 387 |
fcml_fn_parser_result_free( &result ); |
| 388 |
} |
| 389 |
|
| 390 |
void fcml_tf_parser_int_parse_test24(void) { |
| 391 |
fcml_st_parser_result result; |
| 392 |
fcml_fn_parser_result_prepare( &result ); |
| 393 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov dword ptr [0x0000FFFF]", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 394 |
if( result.instruction != NULL ) { |
| 395 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_ADDRESS ); |
| 396 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.address_form, FCML_AF_OFFSET ); |
| 397 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.offset.size, FCML_DS_16 ); |
| 398 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.offset.off16, (fcml_int16_t)0xFFFF ); |
| 399 |
} else { |
| 400 |
STF_FAIL(); |
| 401 |
} |
| 402 |
fcml_fn_parser_result_free( &result ); |
| 403 |
} |
| 404 |
|
| 405 |
void fcml_tf_parser_int_parse_test25(void) { |
| 406 |
fcml_st_parser_result result; |
| 407 |
fcml_fn_parser_result_prepare( &result ); |
| 408 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov dword ptr [0xFF-1]", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 409 |
if( result.instruction != NULL ) { |
| 410 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_ADDRESS ); |
| 411 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.address_form, FCML_AF_OFFSET ); |
| 412 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.offset.size, FCML_DS_16 ); |
| 413 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.offset.off16, 254 ); |
| 414 |
} else { |
| 415 |
STF_FAIL(); |
| 416 |
} |
| 417 |
fcml_fn_parser_result_free( &result ); |
| 418 |
} |
| 419 |
|
| 420 |
void fcml_tf_parser_int_parse_test26(void) { |
| 421 |
fcml_st_parser_result result; |
| 422 |
fcml_fn_parser_result_prepare( &result ); |
| 423 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov dword ptr [-1]", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 424 |
if( result.instruction != NULL ) { |
| 425 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_ADDRESS ); |
| 426 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.address_form, FCML_AF_OFFSET ); |
| 427 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.offset.size, FCML_DS_16 ); |
| 428 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.offset.off16, (fcml_int16_t)0xFFFF ); |
| 429 |
} else { |
| 430 |
STF_FAIL(); |
| 431 |
} |
| 432 |
fcml_fn_parser_result_free( &result ); |
| 433 |
} |
| 434 |
|
| 435 |
void fcml_tf_parser_int_parse_test27(void) { |
| 436 |
fcml_st_parser_result result; |
| 437 |
fcml_fn_parser_result_prepare( &result ); |
| 438 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov dword ptr [0xFFFFFFFFFFFFFFFF]", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 439 |
if( result.instruction != NULL ) { |
| 440 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_ADDRESS ); |
| 441 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.address_form, FCML_AF_OFFSET ); |
| 442 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.offset.size, FCML_DS_64 ); |
| 443 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.offset.off64, 0xFFFFFFFFFFFFFFFFULL ); |
| 444 |
} else { |
| 445 |
STF_FAIL(); |
| 446 |
} |
| 447 |
fcml_fn_parser_result_free( &result ); |
| 448 |
} |
| 449 |
|
| 450 |
void fcml_tf_parser_int_parse_test28(void) { |
| 451 |
fcml_st_parser_result result; |
| 452 |
fcml_fn_parser_result_prepare( &result ); |
| 453 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov dword ptr [eax+0xFFFFFFFFFFFFFFFF]", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 454 |
if( result.instruction != NULL ) { |
| 455 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_ADDRESS ); |
| 456 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.address_form, FCML_AF_COMBINED ); |
| 457 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.effective_address.base.type, FCML_REG_GPR ); |
| 458 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.effective_address.base.reg, FCML_REG_EAX ); |
| 459 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.effective_address.displacement.size, FCML_DS_64 ); |
| 460 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.effective_address.displacement.int64, 0xFFFFFFFFFFFFFFFFULL ); |
| 461 |
} else { |
| 462 |
STF_FAIL(); |
| 463 |
} |
| 464 |
fcml_fn_parser_result_free( &result ); |
| 465 |
} |
| 466 |
|
| 467 |
void fcml_tf_parser_int_parse_test29(void) { |
| 468 |
fcml_st_parser_result result; |
| 469 |
fcml_fn_parser_result_prepare( &result ); |
| 470 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "mov xmmword ptr [eax+0xFFFFFFFFFFFFFFFF]", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 471 |
if( result.instruction != NULL ) { |
| 472 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_ADDRESS ); |
| 473 |
STF_ASSERT_EQUAL( result.instruction->operands[0].hints, FCML_OP_HINT_MULTIMEDIA_INSTRUCTION ); |
| 474 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.address_form, FCML_AF_COMBINED ); |
| 475 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.effective_address.base.type, FCML_REG_GPR ); |
| 476 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.effective_address.base.reg, FCML_REG_EAX ); |
| 477 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.effective_address.displacement.size, FCML_DS_64 ); |
| 478 |
STF_ASSERT_EQUAL( result.instruction->operands[0].address.effective_address.displacement.int64, 0xFFFFFFFFFFFFFFFFULL ); |
| 479 |
} else { |
| 480 |
STF_FAIL(); |
| 481 |
} |
| 482 |
fcml_fn_parser_result_free( &result ); |
| 483 |
} |
| 484 |
|
| 485 |
void fcml_tf_parser_int_parse_test30(void) { |
| 486 |
fcml_st_parser_result result; |
| 487 |
fcml_fn_parser_result_prepare( &result ); |
| 488 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "lock mov 1", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 489 |
if( result.instruction != NULL ) { |
| 490 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 491 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 492 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 493 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, (fcml_uint8_t)1 ); |
| 494 |
STF_ASSERT_EQUAL( result.instruction->prefixes, FCML_PREFIX_LOCK ); |
| 495 |
} else { |
| 496 |
STF_FAIL(); |
| 497 |
} |
| 498 |
fcml_fn_parser_result_free( &result ); |
| 499 |
} |
| 500 |
|
| 501 |
void fcml_tf_parser_int_parse_test31(void) { |
| 502 |
/* Check if multiple prefixes are allowed.*/ |
| 503 |
fcml_st_parser_result result; |
| 504 |
fcml_fn_parser_result_prepare( &result ); |
| 505 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "lock repne repe mov 1", &result ), FCML_CEH_GEC_NO_ERROR ); |
| 506 |
if( result.instruction != NULL ) { |
| 507 |
STF_ASSERT_EQUAL( result.instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 508 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 509 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 510 |
STF_ASSERT_EQUAL( result.instruction->operands[0].immediate.int8, (fcml_uint8_t)1 ); |
| 511 |
STF_ASSERT_EQUAL( result.instruction->prefixes, FCML_PREFIX_LOCK | FCML_PREFIX_REPE | FCML_PREFIX_REPNE ); |
| 512 |
} else { |
| 513 |
STF_FAIL(); |
| 514 |
} |
| 515 |
fcml_fn_parser_result_free( &result ); |
| 516 |
} |
| 517 |
|
| 518 |
void fcml_tf_parser_int_parse_test32(void) { |
| 519 |
/* Duplicated prefixes aren't allowed.*/ |
| 520 |
fcml_st_parser_result result; |
| 521 |
fcml_fn_parser_result_prepare( &result ); |
| 522 |
STF_ASSERT_EQUAL( fcml_fn_parse( &internal_intel_context, "lock lock mov 1", &result ), FCML_CEH_GEC_INVALID_INPUT ); |
| 523 |
if( result.instruction != NULL ) { |
| 524 |
STF_FAIL("Instruction should be NULL."); |
| 525 |
} else if( result.errors.errors ){ |
| 526 |
fcml_st_ceh_error_container *cont = &(result.errors); |
| 527 |
STF_ASSERT_EQUAL( cont->errors->level, FCML_EN_CEH_EL_ERROR ); |
| 528 |
STF_ASSERT_EQUAL( cont->errors->code, ( FCML_CEH_MEC_ERROR_INVALID_SYNTAX ) ); |
| 529 |
STF_ASSERT_STRING_EQUAL( "Doubled prefixes.", cont->errors->message ); |
| 530 |
} else { |
| 531 |
STF_FAIL("Errors can not be null here."); |
| 532 |
} |
| 533 |
fcml_fn_parser_result_free( &result ); |
| 534 |
} |
| 535 |
|
| 536 |
void fcml_tf_parser_int_parse_test_symbols_1(void) { |
| 537 |
fcml_st_parser_result result; |
| 538 |
fcml_fn_parser_result_prepare( &result ); |
| 539 |
fcml_st_parser_context context = {0}; |
| 540 |
context.dialect = internal_dialect_intel; |
| 541 |
context.ip = 0x401000; |
| 542 |
context.symbol_table = NULL; |
| 543 |
context.configuration.alloc_symbol_table_if_needed = FCML_TRUE; |
| 544 |
|
| 545 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label:" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 546 |
STF_ASSERT_PTR_NULL( result.instruction ); |
| 547 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 548 |
STF_ASSERT_PTR_NOT_NULL( context.symbol_table ); |
| 549 |
STF_ASSERT_EQUAL( result.symbol->value, 0x401000 ); |
| 550 |
STF_ASSERT_STRING_EQUAL( result.symbol->symbol, FCML_TEXT( "label" ) ); |
| 551 |
|
| 552 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "_label:" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 553 |
STF_ASSERT_PTR_NULL( result.instruction ); |
| 554 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 555 |
STF_ASSERT_EQUAL( result.symbol->value, 0x401000 ); |
| 556 |
STF_ASSERT_STRING_EQUAL( result.symbol->symbol, FCML_TEXT( "_label" ) ); |
| 557 |
|
| 558 |
fcml_fn_parser_result_free( &result ); |
| 559 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 560 |
} |
| 561 |
|
| 562 |
void fcml_tf_parser_int_parse_test_symbols_2(void) { |
| 563 |
fcml_st_parser_result result; |
| 564 |
fcml_fn_parser_result_prepare( &result ); |
| 565 |
fcml_st_parser_context context = {0}; |
| 566 |
context.dialect = internal_dialect_intel; |
| 567 |
context.configuration.override_labels = FCML_FALSE; |
| 568 |
context.configuration.alloc_symbol_table_if_needed = FCML_TRUE; |
| 569 |
context.ip = 0x401000; |
| 570 |
|
| 571 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax,1" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 572 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 573 |
STF_ASSERT_STRING_EQUAL( result.instruction->mnemonic, "mov" ); |
| 574 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 575 |
STF_ASSERT_EQUAL( result.symbol->value, 0x401000 ); |
| 576 |
STF_ASSERT_STRING_EQUAL( result.symbol->symbol, FCML_TEXT( "label" ) ); |
| 577 |
|
| 578 |
fcml_fn_parser_result_free( &result ); |
| 579 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 580 |
} |
| 581 |
|
| 582 |
void fcml_tf_parser_int_parse_test_symbols_3(void) { |
| 583 |
|
| 584 |
fcml_st_parser_result result; |
| 585 |
|
| 586 |
fcml_fn_parser_result_prepare( &result ); |
| 587 |
|
| 588 |
fcml_st_parser_context context = {0}; |
| 589 |
context.dialect = internal_dialect_intel; |
| 590 |
context.configuration.override_labels = FCML_FALSE; |
| 591 |
context.ip = 0x401000; |
| 592 |
context.configuration.alloc_symbol_table_if_needed = FCML_TRUE; |
| 593 |
|
| 594 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax,1" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 595 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 596 |
STF_ASSERT_STRING_EQUAL( result.instruction->mnemonic, "mov" ); |
| 597 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 598 |
STF_ASSERT_EQUAL( result.symbol->value, 0x401000 ); |
| 599 |
STF_ASSERT_STRING_EQUAL( result.symbol->symbol, FCML_TEXT( "label" ) ); |
| 600 |
|
| 601 |
/* Can not override symbol. */ |
| 602 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax,1" ), &result ), FCML_CEH_GEC_INVALID_INPUT ); |
| 603 |
|
| 604 |
fcml_st_ceh_error_info *error = result.errors.errors; |
| 605 |
STF_ASSERT_PTR_NOT_NULL( error ); |
| 606 |
if( error ) { |
| 607 |
STF_ASSERT_EQUAL( error->code, FCML_CEH_MEC_ERROR_SYMBOL_ALREADY_DEFINED ); |
| 608 |
STF_ASSERT_STRING_EQUAL( error->message, FCML_TEXT( "Symbol already defined: label." ) ); |
| 609 |
} |
| 610 |
|
| 611 |
context.configuration.override_labels = FCML_TRUE; |
| 612 |
|
| 613 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: add eax,1" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 614 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 615 |
STF_ASSERT_STRING_EQUAL( result.instruction->mnemonic, "add" ); |
| 616 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 617 |
STF_ASSERT_EQUAL( result.symbol->value, 0x401000 ); |
| 618 |
STF_ASSERT_STRING_EQUAL( result.symbol->symbol, FCML_TEXT( "label" ) ); |
| 619 |
|
| 620 |
fcml_fn_parser_result_free( &result ); |
| 621 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 622 |
} |
| 623 |
|
| 624 |
|
| 625 |
/* Undefined symbol. */ |
| 626 |
void fcml_tf_parser_int_parse_test_symbols_4(void) { |
| 627 |
fcml_st_parser_result result; |
| 628 |
fcml_fn_parser_result_prepare( &result ); |
| 629 |
fcml_st_parser_context context = {0}; |
| 630 |
context.dialect = internal_dialect_intel; |
| 631 |
context.ip = 0x401000; |
| 632 |
context.configuration.alloc_symbol_table_if_needed = FCML_TRUE; |
| 633 |
|
| 634 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax, symbol" ), &result ), FCML_CEH_GEC_UNDEFINED_SYMBOL ); |
| 635 |
STF_ASSERT_PTR_NULL( result.instruction ); |
| 636 |
STF_ASSERT_PTR_NULL( result.symbol ); |
| 637 |
|
| 638 |
fcml_st_ceh_error_info *error = result.errors.errors; |
| 639 |
STF_ASSERT_PTR_NOT_NULL( error ); |
| 640 |
if( error ) { |
| 641 |
STF_ASSERT_EQUAL( error->code, FCML_CEH_MEC_ERROR_UNDEFINED_SYMBOL ); |
| 642 |
STF_ASSERT_STRING_EQUAL( error->message, FCML_TEXT( "Undefined symbol: symbol." ) ); |
| 643 |
} |
| 644 |
|
| 645 |
fcml_fn_parser_result_free( &result ); |
| 646 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 647 |
} |
| 648 |
|
| 649 |
/* Ignore symbols. */ |
| 650 |
void fcml_tf_parser_int_parse_test_symbols_5(void) { |
| 651 |
|
| 652 |
fcml_st_parser_result result; |
| 653 |
fcml_fn_parser_result_prepare( &result ); |
| 654 |
fcml_st_parser_context context = {0}; |
| 655 |
context.dialect = internal_dialect_intel; |
| 656 |
context.ip = 0x401000; |
| 657 |
context.configuration.ignore_undefined_symbols = FCML_TRUE; |
| 658 |
context.configuration.override_labels = FCML_TRUE; |
| 659 |
context.configuration.alloc_symbol_table_if_needed = FCML_TRUE; |
| 660 |
|
| 661 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax, symbol" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 662 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 663 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 664 |
|
| 665 |
if( result.instruction ) { |
| 666 |
fcml_st_instruction *instruction = result.instruction; |
| 667 |
STF_ASSERT_EQUAL( instruction->operands[1].type, FCML_OT_IMMEDIATE ); |
| 668 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.size, FCML_DS_8 ); |
| 669 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.int8, 0 ); |
| 670 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.is_signed, FCML_TRUE ); |
| 671 |
} |
| 672 |
|
| 673 |
fcml_fn_parser_result_free( &result ); |
| 674 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 675 |
} |
| 676 |
|
| 677 |
/* Use defined symbol in the instruction. */ |
| 678 |
void fcml_tf_parser_int_parse_test_symbols_6(void) { |
| 679 |
|
| 680 |
fcml_st_parser_result result; |
| 681 |
fcml_fn_parser_result_prepare( &result ); |
| 682 |
fcml_st_parser_context context = {0}; |
| 683 |
context.dialect = internal_dialect_intel; |
| 684 |
context.ip = 0x401000; |
| 685 |
context.configuration.ignore_undefined_symbols = FCML_TRUE; |
| 686 |
context.configuration.override_labels = FCML_TRUE; |
| 687 |
context.configuration.alloc_symbol_table_if_needed = FCML_TRUE; |
| 688 |
|
| 689 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax, label" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 690 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 691 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 692 |
|
| 693 |
if( result.instruction ) { |
| 694 |
fcml_st_instruction *instruction = result.instruction; |
| 695 |
STF_ASSERT_EQUAL( instruction->operands[1].type, FCML_OT_IMMEDIATE ); |
| 696 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.size, FCML_DS_32 ); |
| 697 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.int32, 0x401000 ); |
| 698 |
// Symbols are always defined as signed values. |
| 699 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.is_signed, FCML_TRUE ); |
| 700 |
} |
| 701 |
|
| 702 |
fcml_fn_parser_result_free( &result ); |
| 703 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 704 |
} |
| 705 |
|
| 706 |
/* Multpile symbols in expression. */ |
| 707 |
void fcml_tf_parser_int_parse_test_symbols_7(void) { |
| 708 |
|
| 709 |
fcml_st_parser_result result; |
| 710 |
fcml_fn_parser_result_prepare( &result ); |
| 711 |
fcml_st_parser_context context = {0}; |
| 712 |
context.dialect = internal_dialect_intel; |
| 713 |
context.ip = 0x401000; |
| 714 |
context.configuration.ignore_undefined_symbols = FCML_TRUE; |
| 715 |
context.configuration.override_labels = FCML_TRUE; |
| 716 |
context.symbol_table = fcml_fn_symbol_table_alloc(); |
| 717 |
if( !context.symbol_table ) { |
| 718 |
STF_FAIL("Out of memory."); |
| 719 |
return; |
| 720 |
} |
| 721 |
|
| 722 |
STF_ASSERT_EQUAL( fcml_fn_symbol_add_raw( context.symbol_table, FCML_TEXT("symbol_1"), 10 ), FCML_CEH_GEC_NO_ERROR ); |
| 723 |
STF_ASSERT_EQUAL( fcml_fn_symbol_add_raw( context.symbol_table, FCML_TEXT("symbol_2"), 5 ), FCML_CEH_GEC_NO_ERROR ); |
| 724 |
STF_ASSERT_EQUAL( fcml_fn_symbol_add_raw( context.symbol_table, FCML_TEXT("symbol_3"), 2 ), FCML_CEH_GEC_NO_ERROR ); |
| 725 |
|
| 726 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax, label + ( ( symbol_1 * symbol_2 ) / symbol_3 )" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 727 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 728 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 729 |
|
| 730 |
if( result.instruction ) { |
| 731 |
fcml_st_instruction *instruction = result.instruction; |
| 732 |
STF_ASSERT_EQUAL( instruction->operands[1].type, FCML_OT_IMMEDIATE ); |
| 733 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.size, FCML_DS_32 ); |
| 734 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.int32, 0x401000 + 25 ); |
| 735 |
STF_ASSERT_EQUAL( instruction->operands[1].immediate.is_signed, FCML_FALSE ); |
| 736 |
} |
| 737 |
|
| 738 |
fcml_fn_parser_result_free( &result ); |
| 739 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 740 |
} |
| 741 |
|
| 742 |
/* Extracting symbols. */ |
| 743 |
void fcml_tf_parser_int_parse_test_symbols_8(void) { |
| 744 |
|
| 745 |
fcml_st_parser_result result; |
| 746 |
|
| 747 |
fcml_fn_parser_result_prepare( &result ); |
| 748 |
|
| 749 |
fcml_st_parser_context context = {0}; |
| 750 |
context.dialect = internal_dialect_intel; |
| 751 |
context.ip = 0x401000; |
| 752 |
context.configuration.ignore_undefined_symbols = FCML_TRUE; |
| 753 |
context.configuration.override_labels = FCML_TRUE; |
| 754 |
context.symbol_table = fcml_fn_symbol_table_alloc(); |
| 755 |
if( !context.symbol_table ) { |
| 756 |
STF_FAIL("Out of memory."); |
| 757 |
return; |
| 758 |
} |
| 759 |
|
| 760 |
STF_ASSERT_EQUAL( fcml_fn_symbol_add_raw( context.symbol_table, FCML_TEXT("symbol_1"), 10 ), FCML_CEH_GEC_NO_ERROR ); |
| 761 |
STF_ASSERT_EQUAL( fcml_fn_symbol_add_raw( context.symbol_table, FCML_TEXT("symbol_2"), 5 ), FCML_CEH_GEC_NO_ERROR ); |
| 762 |
STF_ASSERT_EQUAL( fcml_fn_symbol_add_raw( context.symbol_table, FCML_TEXT("symbol_3"), 2 ), FCML_CEH_GEC_NO_ERROR ); |
| 763 |
|
| 764 |
fcml_st_parser_ast ast = {0}; |
| 765 |
fcml_ceh_error error = fcml_fn_parse_to_ast( &context, FCML_TEXT( "label: mov eax, label + ( ( symbol_1 * symbol_2 ) / symbol_3 )" ), &ast ); |
| 766 |
|
| 767 |
if( !error ) { |
| 768 |
|
| 769 |
STF_ASSERT_PTR_NOT_NULL( ast.symbol ); |
| 770 |
STF_ASSERT_PTR_NOT_NULL( ast.tree ); |
| 771 |
|
| 772 |
if( ast.tree ) { |
| 773 |
fcml_st_coll_list *list = NULL; |
| 774 |
error = fcml_fn_ast_extract_used_symbols( ast.tree, &list ); |
| 775 |
if( !error ) { |
| 776 |
STF_ASSERT_EQUAL( list->size, 4 ); |
| 777 |
fcml_fn_coll_list_free( list, NULL, NULL ); |
| 778 |
} |
| 779 |
|
| 780 |
} |
| 781 |
|
| 782 |
} |
| 783 |
|
| 784 |
fcml_fn_parser_free_ast( &ast ); |
| 785 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 786 |
} |
| 787 |
|
| 788 |
void fcml_tf_parser_int_parse_test_symbols_9(void) { |
| 789 |
fcml_st_parser_result result; |
| 790 |
fcml_fn_parser_result_prepare( &result ); |
| 791 |
fcml_st_parser_context context = {0}; |
| 792 |
context.dialect = internal_dialect_intel; |
| 793 |
context.ip = 0x401000; |
| 794 |
context.symbol_table = NULL; |
| 795 |
context.configuration.disable_symbols_declaration = FCML_TRUE; |
| 796 |
|
| 797 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label:" ), &result ), FCML_CEH_GEC_UNSUPPORTED_LABEL_DECLARATION ); |
| 798 |
STF_ASSERT_PTR_NULL( result.instruction ); |
| 799 |
STF_ASSERT_PTR_NULL( result.symbol ); |
| 800 |
STF_ASSERT_PTR_NULL( result.errors.errors ); |
| 801 |
STF_ASSERT_PTR_NULL( result.errors.last_error ); |
| 802 |
|
| 803 |
fcml_fn_parser_result_free( &result ); |
| 804 |
} |
| 805 |
|
| 806 |
void fcml_tf_parser_int_parse_test_symbols_10(void) { |
| 807 |
|
| 808 |
fcml_st_parser_result result; |
| 809 |
fcml_fn_parser_result_prepare( &result ); |
| 810 |
fcml_st_parser_context context = {0}; |
| 811 |
context.dialect = internal_dialect_intel; |
| 812 |
context.ip = 0x401000; |
| 813 |
context.symbol_table = NULL; |
| 814 |
context.configuration.disable_symbols_declaration = FCML_FALSE; |
| 815 |
context.configuration.alloc_symbol_table_if_needed = FCML_FALSE; |
| 816 |
|
| 817 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax, 1" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 818 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 819 |
STF_ASSERT_PTR_NULL( result.symbol ); |
| 820 |
STF_ASSERT_PTR_NULL( result.errors.errors ); |
| 821 |
STF_ASSERT_PTR_NULL( result.errors.last_error ); |
| 822 |
STF_ASSERT_PTR_NULL( context.symbol_table ); |
| 823 |
|
| 824 |
fcml_fn_parser_result_free( &result ); |
| 825 |
} |
| 826 |
|
| 827 |
void fcml_tf_parser_int_parse_test_symbols_11(void) { |
| 828 |
|
| 829 |
/* Symbol table not found and not allocated. */ |
| 830 |
fcml_st_parser_result result; |
| 831 |
fcml_fn_parser_result_prepare( &result ); |
| 832 |
fcml_st_parser_context context = {0}; |
| 833 |
context.dialect = internal_dialect_intel; |
| 834 |
context.configuration.override_labels = FCML_FALSE; |
| 835 |
context.configuration.alloc_symbol_table_if_needed = FCML_FALSE; |
| 836 |
context.ip = 0x401000; |
| 837 |
|
| 838 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: mov eax,1" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 839 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 840 |
STF_ASSERT_STRING_EQUAL( result.instruction->mnemonic, "mov" ); |
| 841 |
STF_ASSERT_PTR_NULL( result.symbol ); |
| 842 |
STF_ASSERT_PTR_NULL( context.symbol_table ); |
| 843 |
|
| 844 |
fcml_fn_parser_result_free( &result ); |
| 845 |
} |
| 846 |
|
| 847 |
|
| 848 |
/* Pseudo operations operands parsing. */ |
| 849 |
void fcml_tf_parser_intel_parse_test_pseudo_operation_1(void) { |
| 850 |
|
| 851 |
fcml_st_parser_result result; |
| 852 |
fcml_fn_parser_result_prepare( &result ); |
| 853 |
fcml_st_parser_context context = {0}; |
| 854 |
context.dialect = internal_dialect_intel; |
| 855 |
context.ip = 0x401000; |
| 856 |
context.configuration.ignore_undefined_symbols = FCML_TRUE; |
| 857 |
context.configuration.override_labels = FCML_TRUE; |
| 858 |
context.configuration.alloc_symbol_table_if_needed = FCML_TRUE; |
| 859 |
|
| 860 |
STF_ASSERT_EQUAL( fcml_fn_parse( &context, FCML_TEXT( "label: db 0x12" ), &result ), FCML_CEH_GEC_NO_ERROR ); |
| 861 |
STF_ASSERT_PTR_NOT_NULL( result.instruction ); |
| 862 |
STF_ASSERT_PTR_NOT_NULL( result.symbol ); |
| 863 |
|
| 864 |
if( result.instruction ) { |
| 865 |
fcml_st_instruction *instruction = result.instruction; |
| 866 |
STF_ASSERT_STRING_EQUAL( "db", result.instruction->mnemonic ); |
| 867 |
STF_ASSERT_EQUAL( 1, instruction->operands_count ); |
| 868 |
STF_ASSERT_EQUAL( instruction->operands[0].type, FCML_OT_IMMEDIATE ); |
| 869 |
STF_ASSERT_EQUAL( instruction->operands[0].immediate.size, FCML_DS_8 ); |
| 870 |
STF_ASSERT_EQUAL( instruction->operands[0].immediate.int8, 0x12 ); |
| 871 |
STF_ASSERT_EQUAL( instruction->operands[0].immediate.is_signed, FCML_FALSE ); |
| 872 |
} |
| 873 |
|
| 874 |
fcml_fn_parser_result_free( &result ); |
| 875 |
fcml_fn_symbol_table_free( context.symbol_table ); |
| 876 |
} |
| 877 |
|
| 878 |
void fcml_tf_parser_int_parse_test_decorator_bcast(void) { |
| 879 |
fcml_st_parser_result result; |
| 880 |
fcml_fn_parser_result_prepare(&result); |
| 881 |
STF_ASSERT_EQUAL( |
| 882 |
fcml_fn_parse(&internal_intel_context, "vaddpd [eax]{1to8}", |
| 883 |
&result), FCML_CEH_GEC_NO_ERROR); |
| 884 |
if (result.instruction != NULL) { |
| 885 |
fcml_st_operand *operand = &(result.instruction->operands[0]); |
| 886 |
STF_ASSERT_EQUAL(operand->type, FCML_OT_ADDRESS); |
| 887 |
STF_ASSERT_EQUAL(operand->address.address_form, FCML_AF_COMBINED); |
| 888 |
STF_ASSERT_EQUAL(operand->address.effective_address.base.type, |
| 889 |
FCML_REG_GPR); |
| 890 |
STF_ASSERT_EQUAL(operand->address.effective_address.base.reg, |
| 891 |
FCML_REG_EAX); |
| 892 |
STF_ASSERT_EQUAL(operand->decorators.bcast.is_not_null, FCML_TRUE); |
| 893 |
STF_ASSERT_EQUAL(operand->decorators.bcast.value, 8); |
| 894 |
} else { |
| 895 |
STF_FAIL(); |
| 896 |
} |
| 897 |
fcml_fn_parser_result_free(&result); |
| 898 |
} |
| 899 |
|
| 900 |
void fcml_tf_parser_int_parse_test_decorator_opmask(void) { |
| 901 |
fcml_st_parser_result result; |
| 902 |
fcml_fn_parser_result_prepare(&result); |
| 903 |
STF_ASSERT_EQUAL( |
| 904 |
fcml_fn_parse(&internal_intel_context, "vaddpd zmm1{k1}", |
| 905 |
&result), FCML_CEH_GEC_NO_ERROR); |
| 906 |
if (result.instruction != NULL) { |
| 907 |
fcml_st_operand *operand = &(result.instruction->operands[0]); |
| 908 |
STF_ASSERT_EQUAL(operand->type, FCML_OT_REGISTER); |
| 909 |
STF_ASSERT_EQUAL(operand->reg.type, FCML_REG_SIMD); |
| 910 |
STF_ASSERT_EQUAL(operand->reg.reg, FCML_REG_ZMM1); |
| 911 |
STF_ASSERT_EQUAL(operand->reg.size, FCML_DS_512); |
| 912 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.type, |
| 913 |
FCML_REG_OPMASK); |
| 914 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.size, |
| 915 |
FCML_DS_64); |
| 916 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.reg, |
| 917 |
FCML_REG_K1); |
| 918 |
STF_ASSERT_EQUAL(operand->decorators.z, FCML_FALSE); |
| 919 |
|
| 920 |
} else { |
| 921 |
STF_FAIL(); |
| 922 |
} |
| 923 |
fcml_fn_parser_result_free(&result); |
| 924 |
} |
| 925 |
|
| 926 |
void fcml_tf_parser_int_parse_test_decorator_opmask_k_z_for_addressing(void) { |
| 927 |
fcml_st_parser_result result; |
| 928 |
fcml_fn_parser_result_prepare(&result); |
| 929 |
STF_ASSERT_EQUAL( |
| 930 |
fcml_fn_parse(&internal_intel_context, "vaddpd cs:[rax+rbx]{k4}{z}", |
| 931 |
&result), FCML_CEH_GEC_NO_ERROR); |
| 932 |
if (result.instruction != NULL) { |
| 933 |
fcml_st_operand *operand = &(result.instruction->operands[0]); |
| 934 |
|
| 935 |
STF_ASSERT_EQUAL(result.instruction->operands[0]. |
| 936 |
type, FCML_OT_ADDRESS); |
| 937 |
STF_ASSERT_EQUAL(result.instruction->operands[0]. |
| 938 |
address.address_form, FCML_AF_COMBINED); |
| 939 |
STF_ASSERT_EQUAL(result.instruction->operands[0]. |
| 940 |
address.effective_address.base.size, FCML_DS_64); |
| 941 |
STF_ASSERT_EQUAL(result.instruction->operands[0]. |
| 942 |
address.effective_address.base.reg, FCML_REG_RAX); |
| 943 |
STF_ASSERT_EQUAL(result.instruction->operands[0]. |
| 944 |
address.effective_address.index.size, FCML_DS_64); |
| 945 |
STF_ASSERT_EQUAL(result.instruction->operands[0]. |
| 946 |
address.effective_address.index.reg, FCML_REG_RBX); |
| 947 |
STF_ASSERT_EQUAL(result.instruction->operands[0]. |
| 948 |
address.segment_selector.segment_selector.reg, FCML_REG_CS); |
| 949 |
|
| 950 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.type, |
| 951 |
FCML_REG_OPMASK); |
| 952 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.size, |
| 953 |
FCML_DS_64); |
| 954 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.reg, |
| 955 |
FCML_REG_K4); |
| 956 |
STF_ASSERT_EQUAL(operand->decorators.z, FCML_TRUE); |
| 957 |
} else { |
| 958 |
STF_FAIL(); |
| 959 |
} |
| 960 |
fcml_fn_parser_result_free(&result); |
| 961 |
} |
| 962 |
|
| 963 |
void fcml_tf_parser_int_parse_test_decorator_opmask_k(void) { |
| 964 |
fcml_st_parser_result result; |
| 965 |
fcml_fn_parser_result_prepare(&result); |
| 966 |
STF_ASSERT_EQUAL( |
| 967 |
fcml_fn_parse(&internal_intel_context, "vaddpd zmm31{k4}{z}", |
| 968 |
&result), FCML_CEH_GEC_NO_ERROR); |
| 969 |
if (result.instruction != NULL) { |
| 970 |
fcml_st_operand *operand = &(result.instruction->operands[0]); |
| 971 |
STF_ASSERT_EQUAL(operand->type, FCML_OT_REGISTER); |
| 972 |
STF_ASSERT_EQUAL(operand->reg.type, FCML_REG_SIMD); |
| 973 |
STF_ASSERT_EQUAL(operand->reg.reg, FCML_REG_ZMM31); |
| 974 |
STF_ASSERT_EQUAL(operand->reg.size, FCML_DS_512); |
| 975 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.type, |
| 976 |
FCML_REG_OPMASK); |
| 977 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.size, |
| 978 |
FCML_DS_64); |
| 979 |
STF_ASSERT_EQUAL(operand->decorators.operand_mask_reg.reg, |
| 980 |
FCML_REG_K4); |
| 981 |
STF_ASSERT_EQUAL(operand->decorators.z, FCML_TRUE); |
| 982 |
} else { |
| 983 |
STF_FAIL(); |
| 984 |
} |
| 985 |
fcml_fn_parser_result_free(&result); |
| 986 |
} |
| 987 |
|
| 988 |
void fcml_tf_parser_int_parse_test_decorator_z(void) { |
| 989 |
fcml_st_parser_result result; |
| 990 |
fcml_fn_parser_result_prepare(&result); |
| 991 |
STF_ASSERT_EQUAL( |
| 992 |
fcml_fn_parse(&internal_intel_context, "vaddpd zmm31{z}", |
| 993 |
&result), FCML_CEH_GEC_NO_ERROR); |
| 994 |
if (result.instruction != NULL) { |
| 995 |
fcml_st_operand *operand = &(result.instruction->operands[0]); |
| 996 |
STF_ASSERT_EQUAL(operand->decorators.z, FCML_TRUE); |
| 997 |
} else { |
| 998 |
STF_FAIL(); |
| 999 |
} |
| 1000 |
fcml_fn_parser_result_free(&result); |
| 1001 |
} |
| 1002 |
|
| 1003 |
void fcml_tf_parser_int_parse_test_decorator_er(void) { |
| 1004 |
fcml_st_parser_result result; |
| 1005 |
fcml_fn_parser_result_prepare(&result); |
| 1006 |
STF_ASSERT_EQUAL( |
| 1007 |
fcml_fn_parse(&internal_intel_context, "vaddpd {ru-sae}", |
| 1008 |
&result), FCML_CEH_GEC_NO_ERROR); |
| 1009 |
if (result.instruction != NULL) { |
| 1010 |
fcml_st_operand *operand = &(result.instruction->operands[0]); |
| 1011 |
STF_ASSERT_EQUAL(operand->type, FCML_OT_VIRTUAL); |
| 1012 |
STF_ASSERT_EQUAL(operand->decorators.er.is_not_null, FCML_TRUE); |
| 1013 |
STF_ASSERT_EQUAL(operand->decorators.er.value, FCML_ER_RU_SAE); |
| 1014 |
} else { |
| 1015 |
STF_FAIL(); |
| 1016 |
} |
| 1017 |
fcml_fn_parser_result_free(&result); |
| 1018 |
} |
| 1019 |
|
| 1020 |
void fcml_tf_parser_int_parse_test_decorator_sae(void) { |
| 1021 |
fcml_st_parser_result result; |
| 1022 |
fcml_fn_parser_result_prepare(&result); |
| 1023 |
STF_ASSERT_EQUAL( |
| 1024 |
fcml_fn_parse(&internal_intel_context, "vaddpd {sae}", |
| 1025 |
&result), FCML_CEH_GEC_NO_ERROR); |
| 1026 |
if (result.instruction != NULL) { |
| 1027 |
fcml_st_operand *operand = &(result.instruction->operands[0]); |
| 1028 |
STF_ASSERT_EQUAL(operand->type, FCML_OT_VIRTUAL); |
| 1029 |
STF_ASSERT_EQUAL(operand->decorators.sae, FCML_TRUE); |
| 1030 |
} else { |
| 1031 |
STF_FAIL(); |
| 1032 |
} |
| 1033 |
fcml_fn_parser_result_free(&result); |
| 1034 |
} |
| 1035 |
|
| 1036 |
fcml_stf_test_case fcml_ti_parser[] = { |
| 1037 |
{ "fcml_tf_parser_int_parse_test1", fcml_tf_parser_int_parse_test1 }, |
| 1038 |
{ "fcml_tf_parser_int_parse_test2", fcml_tf_parser_int_parse_test2 }, |
| 1039 |
{ "fcml_tf_parser_int_parse_test3", fcml_tf_parser_int_parse_test3 }, |
| 1040 |
{ "fcml_tf_parser_int_parse_test4", fcml_tf_parser_int_parse_test4 }, |
| 1041 |
{ "fcml_tf_parser_int_parse_test5", fcml_tf_parser_int_parse_test5 }, |
| 1042 |
{ "fcml_tf_parser_int_parse_test6", fcml_tf_parser_int_parse_test6 }, |
| 1043 |
{ "fcml_tf_parser_int_parse_test7", fcml_tf_parser_int_parse_test7 }, |
| 1044 |
{ "fcml_tf_parser_int_parse_test8", fcml_tf_parser_int_parse_test8 }, |
| 1045 |
{ "fcml_tf_parser_int_parse_test9", fcml_tf_parser_int_parse_test9 }, |
| 1046 |
{ "fcml_tf_parser_int_parse_test10", fcml_tf_parser_int_parse_test10 }, |
| 1047 |
{ "fcml_tf_parser_int_parse_test11", fcml_tf_parser_int_parse_test11 }, |
| 1048 |
{ "fcml_tf_parser_int_parse_test12", fcml_tf_parser_int_parse_test12 }, |
| 1049 |
{ "fcml_tf_parser_int_parse_test13", fcml_tf_parser_int_parse_test13 }, |
| 1050 |
{ "fcml_tf_parser_int_parse_test14", fcml_tf_parser_int_parse_test14 }, |
| 1051 |
{ "fcml_tf_parser_int_parse_test15", fcml_tf_parser_int_parse_test15 }, |
| 1052 |
{ "fcml_tf_parser_int_parse_test16", fcml_tf_parser_int_parse_test16 }, |
| 1053 |
{ "fcml_tf_parser_int_parse_test17", fcml_tf_parser_int_parse_test17 }, |
| 1054 |
{ "fcml_tf_parser_int_parse_test18", fcml_tf_parser_int_parse_test18 }, |
| 1055 |
{ "fcml_tf_parser_int_parse_test19", fcml_tf_parser_int_parse_test19 }, |
| 1056 |
{ "fcml_tf_parser_int_parse_test20", fcml_tf_parser_int_parse_test20 }, |
| 1057 |
{ "fcml_tf_parser_int_parse_test21", fcml_tf_parser_int_parse_test21 }, |
| 1058 |
{ "fcml_tf_parser_int_parse_test22", fcml_tf_parser_int_parse_test22 }, |
| 1059 |
{ "fcml_tf_parser_int_parse_test23", fcml_tf_parser_int_parse_test23 }, |
| 1060 |
{ "fcml_tf_parser_int_parse_test24", fcml_tf_parser_int_parse_test24 }, |
| 1061 |
{ "fcml_tf_parser_int_parse_test25", fcml_tf_parser_int_parse_test25 }, |
| 1062 |
{ "fcml_tf_parser_int_parse_test26", fcml_tf_parser_int_parse_test26 }, |
| 1063 |
{ "fcml_tf_parser_int_parse_test27", fcml_tf_parser_int_parse_test27 }, |
| 1064 |
{ "fcml_tf_parser_int_parse_test28", fcml_tf_parser_int_parse_test28 }, |
| 1065 |
{ "fcml_tf_parser_int_parse_test29", fcml_tf_parser_int_parse_test29 }, |
| 1066 |
{ "fcml_tf_parser_int_parse_test30", fcml_tf_parser_int_parse_test30 }, |
| 1067 |
{ "fcml_tf_parser_int_parse_test31", fcml_tf_parser_int_parse_test31 }, |
| 1068 |
{ "fcml_tf_parser_int_parse_test32", fcml_tf_parser_int_parse_test32 }, |
| 1069 |
{ "fcml_tf_parser_int_parse_test_symbols_1", fcml_tf_parser_int_parse_test_symbols_1 }, |
| 1070 |
{ "fcml_tf_parser_int_parse_test_symbols_2", fcml_tf_parser_int_parse_test_symbols_2 }, |
| 1071 |
{ "fcml_tf_parser_int_parse_test_symbols_3", fcml_tf_parser_int_parse_test_symbols_3 }, |
| 1072 |
{ "fcml_tf_parser_int_parse_test_symbols_4", fcml_tf_parser_int_parse_test_symbols_4 }, |
| 1073 |
{ "fcml_tf_parser_int_parse_test_symbols_5", fcml_tf_parser_int_parse_test_symbols_5 }, |
| 1074 |
{ "fcml_tf_parser_int_parse_test_symbols_6", fcml_tf_parser_int_parse_test_symbols_6 }, |
| 1075 |
{ "fcml_tf_parser_int_parse_test_symbols_7", fcml_tf_parser_int_parse_test_symbols_7 }, |
| 1076 |
{ "fcml_tf_parser_int_parse_test_symbols_8", fcml_tf_parser_int_parse_test_symbols_8 }, |
| 1077 |
{ "fcml_tf_parser_int_parse_test_symbols_9", fcml_tf_parser_int_parse_test_symbols_9 }, |
| 1078 |
{ "fcml_tf_parser_int_parse_test_symbols_10", fcml_tf_parser_int_parse_test_symbols_10 }, |
| 1079 |
{ "fcml_tf_parser_int_parse_test_symbols_11", fcml_tf_parser_int_parse_test_symbols_11 }, |
| 1080 |
{ "fcml_tf_parser_intel_parse_test_pseudo_operation_1", fcml_tf_parser_intel_parse_test_pseudo_operation_1 }, |
| 1081 |
{ "fcml_tf_parser_int_parse_test_decorator_bcast", |
| 1082 |
fcml_tf_parser_int_parse_test_decorator_bcast }, |
| 1083 |
{ "fcml_tf_parser_int_parse_test_decorator_opmask", |
| 1084 |
fcml_tf_parser_int_parse_test_decorator_opmask }, |
| 1085 |
{ "fcml_tf_parser_int_parse_test_decorator_opmask_k", |
| 1086 |
fcml_tf_parser_int_parse_test_decorator_opmask_k }, |
| 1087 |
{ "fcml_tf_parser_int_parse_test_decorator_z", |
| 1088 |
fcml_tf_parser_int_parse_test_decorator_z }, |
| 1089 |
{ "fcml_tf_parser_int_parse_test_decorator_opmask_k_z_for_addressing", |
| 1090 |
fcml_tf_parser_int_parse_test_decorator_opmask_k_z_for_addressing }, |
| 1091 |
{ "fcml_tf_parser_int_parse_test_decorator_er", |
| 1092 |
fcml_tf_parser_int_parse_test_decorator_er }, |
| 1093 |
{ "fcml_tf_parser_int_parse_test_decorator_sae", |
| 1094 |
fcml_tf_parser_int_parse_test_decorator_sae }, |
| 1095 |
FCML_STF_NULL_TEST |
| 1096 |
}; |
| 1097 |
|
| 1098 |
fcml_stf_test_suite fcml_si_intel_parser = { |
| 1099 |
"suite-fcml-parser", fcml_tf_parser_suite_init, fcml_tf_parser_suite_cleanup, fcml_ti_parser |
| 1100 |
}; |
| 1101 |
|