Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 | 11 |
| 12 #include "native_client/src/include/elf32.h" | 12 #include "native_client/src/include/elf32.h" |
| 13 #include "native_client/src/include/elf64.h" | 13 #include "native_client/src/include/elf64.h" |
| 14 #include "native_client/src/shared/platform/nacl_check.h" | 14 #include "native_client/src/shared/platform/nacl_check.h" |
| 15 #include "native_client/src/shared/utils/types.h" | 15 #include "native_client/src/shared/utils/types.h" |
| 16 #include "native_client/src/trusted/validator_ragel/unreviewed/decoder.h" | 16 #include "native_client/src/trusted/validator_ragel/decoder.h" |
| 17 | 17 |
| 18 /* This is a copy of NaClLog from shared/platform/nacl_log.c to avoid | 18 /* This is a copy of NaClLog from shared/platform/nacl_log.c to avoid |
| 19 * linking in code in NaCl shared code in the unreviewed/Makefile and be able to | 19 * linking in code in NaCl shared code in the unreviewed/Makefile and be able to |
| 20 * use CHECK(). | 20 * use CHECK(). |
| 21 | 21 |
| 22 * TODO(khim): remove the copy of NaClLog implementation as soon as | 22 * TODO(khim): remove the copy of NaClLog implementation as soon as |
| 23 * unreviewed/Makefile is eliminated. | 23 * unreviewed/Makefile is eliminated. |
| 24 */ | 24 */ |
| 25 void NaClLog(int detail_level, char const *fmt, ...) { | 25 void NaClLog(int detail_level, char const *fmt, ...) { |
| 26 va_list ap; | 26 va_list ap; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 *result_size = file_size; | 70 *result_size = file_size; |
| 71 } | 71 } |
| 72 | 72 |
| 73 struct DecodeState { | 73 struct DecodeState { |
| 74 uint8_t width; | 74 uint8_t width; |
| 75 const uint8_t *fwait; /* Set to true if fwait is detetected. */ | 75 const uint8_t *fwait; /* Set to true if fwait is detetected. */ |
| 76 const uint8_t *offset; | 76 const uint8_t *offset; |
| 77 int ia32_mode; | 77 int ia32_mode; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 void ProcessInstruction(const uint8_t *begin, const uint8_t *end, | 80 void ProcessInstruction(const uint8_t *begin, const uint8_t *end, |
|
Brad Chen
2012/10/05 16:47:21
I am still waiting for you to break up this large
khim
2012/10/15 16:38:57
It made no sense to break it up in the current for
Brad Chen
2012/10/16 00:16:55
Here are rules that I generally assume apply durin
| |
| 81 struct instruction *instruction, void *userdata) { | 81 struct Instruction *instruction, void *userdata) { |
| 82 const char *instruction_name = instruction->name; | 82 const char *instruction_name = instruction->name; |
| 83 unsigned char operands_count = instruction->operands_count; | 83 unsigned char operands_count = instruction->operands_count; |
| 84 unsigned char rex_prefix = instruction->prefix.rex; | 84 unsigned char rex_prefix = instruction->prefix.rex; |
| 85 enum register_name rm_index = instruction->rm.index; | 85 enum OperandName rm_index = instruction->rm.index; |
| 86 enum register_name rm_base = instruction->rm.base; | 86 enum OperandName rm_base = instruction->rm.base; |
| 87 #ifdef _MSC_VER | |
| 88 Bool data16_prefix = instruction->prefix.data16; | 87 Bool data16_prefix = instruction->prefix.data16; |
| 89 #else | |
| 90 _Bool data16_prefix = instruction->prefix.data16; | |
| 91 #endif | |
| 92 const uint8_t *p; | 88 const uint8_t *p; |
| 93 char delimeter = ' '; | 89 char delimeter = ' '; |
| 94 int print_rip = FALSE; | 90 int print_rip = FALSE; |
| 95 int rex_bits = 0; | 91 int rex_bits = 0; |
| 96 int maybe_rex_bits = 0; | 92 int maybe_rex_bits = 0; |
| 97 int show_name_suffix = FALSE; | 93 int show_name_suffix = FALSE; |
| 98 int empty_rex_prefix_ok = FALSE; | 94 int empty_rex_prefix_ok = FALSE; |
| 99 #define print_name(x) (printf((x)), shown_name += strlen((x))) | 95 #define print_name(x) (printf((x)), shown_name += strlen((x))) |
| 100 size_t shown_name = 0; | 96 size_t shown_name = 0; |
| 101 int i, operand_type; | 97 int i, operand_type; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 if (operands_count > 0) { | 232 if (operands_count > 0) { |
| 237 char rexw_counted = FALSE; | 233 char rexw_counted = FALSE; |
| 238 show_name_suffix = TRUE; | 234 show_name_suffix = TRUE; |
| 239 for (i=operands_count-1; i>=0; --i) { | 235 for (i=operands_count-1; i>=0; --i) { |
| 240 if (instruction->operands[i].name == JMP_TO) { | 236 if (instruction->operands[i].name == JMP_TO) { |
| 241 /* Most control flow instructions never use suffixes, but "call" and | 237 /* Most control flow instructions never use suffixes, but "call" and |
| 242 "jmp" do... unless byte offset is used. */ | 238 "jmp" do... unless byte offset is used. */ |
| 243 if ((!strcmp(instruction_name, "call")) || | 239 if ((!strcmp(instruction_name, "call")) || |
| 244 (!strcmp(instruction_name, "jmp"))) { | 240 (!strcmp(instruction_name, "jmp"))) { |
| 245 switch (instruction->operands[i].type) { | 241 switch (instruction->operands[i].type) { |
| 246 case OPERAND_SIZE_8_BIT: show_name_suffix = FALSE; break; | 242 case OPERAND_TYPE_8_BIT: show_name_suffix = FALSE; break; |
| 247 case OPERAND_SIZE_16_BIT: show_name_suffix = 'w'; break; | 243 case OPERAND_TYPE_16_BIT: show_name_suffix = 'w'; break; |
| 248 case OPERAND_SIZE_32_BIT: | 244 case OPERAND_TYPE_32_BIT: |
| 249 if (((struct DecodeState *)userdata)->ia32_mode) { | 245 if (((struct DecodeState *)userdata)->ia32_mode) { |
| 250 show_name_suffix = FALSE; | 246 show_name_suffix = FALSE; |
| 251 } else { | 247 } else { |
| 252 show_name_suffix = 'q'; | 248 show_name_suffix = 'q'; |
| 253 rex_bits += (rex_prefix & 0x08) >> 3; | 249 rex_bits += (rex_prefix & 0x08) >> 3; |
| 254 rexw_counted = TRUE; | 250 rexw_counted = TRUE; |
| 255 } | 251 } |
| 256 break; | 252 break; |
| 257 case OPERAND_SIZE_2_BIT: | 253 case OPERAND_TYPE_2_BIT: |
| 258 case OPERAND_SIZE_64_BIT: | 254 case OPERAND_TYPE_64_BIT: |
| 259 case OPERAND_SIZE_128_BIT: | 255 case OPERAND_TYPE_128_BIT: |
| 260 case OPERAND_SIZE_256_BIT: | 256 case OPERAND_TYPE_256_BIT: |
| 261 case OPERAND_FLOAT_SIZE_16_BIT: | 257 case OPERAND_TYPE_FLOAT_32_BIT: |
| 262 case OPERAND_FLOAT_SIZE_32_BIT: | 258 case OPERAND_TYPE_FLOAT_64_BIT: |
| 263 case OPERAND_FLOAT_SIZE_64_BIT: | 259 case OPERAND_TYPE_FLOAT_80_BIT: |
| 264 case OPERAND_FLOAT_SIZE_80_BIT: | 260 case OPERAND_TYPE_X87_16_BIT: |
| 265 case OPERAND_X87_SIZE_16_BIT: | 261 case OPERAND_TYPE_X87_32_BIT: |
| 266 case OPERAND_X87_SIZE_32_BIT: | 262 case OPERAND_TYPE_X87_64_BIT: |
| 267 case OPERAND_X87_SIZE_64_BIT: | 263 case OPERAND_TYPE_X87_BCD: |
| 268 case OPERAND_X87_BCD: | 264 case OPERAND_TYPE_X87_ENV: |
| 269 case OPERAND_X87_ENV: | 265 case OPERAND_TYPE_X87_STATE: |
| 270 case OPERAND_X87_STATE: | 266 case OPERAND_TYPE_X87_MMX_XMM_STATE: |
| 271 case OPERAND_X87_MMX_MM_STATE: | 267 case OPERAND_TYPE_ST: |
| 272 case OPERAND_ST: | 268 case OPERAND_TYPE_SELECTOR: |
| 273 case OPERAND_SELECTOR: | 269 case OPERAND_TYPE_FAR_PTR: |
| 274 case OPERAND_FAR_PTR: | 270 case OPERAND_TYPE_SEGMENT_REGISTER: |
| 275 case OPERAND_SEGMENT_REGISTER: | 271 case OPERAND_TYPE_CONTROL_REGISTER: |
| 276 case OPERAND_CONTROL_REGISTER: | 272 case OPERAND_TYPE_DEBUG_REGISTER: |
| 277 case OPERAND_DEBUG_REGISTER: | 273 case OPERAND_TYPE_MMX: |
| 278 case OPERAND_MMX: | 274 case OPERAND_TYPE_XMM: |
| 279 case OPERAND_XMM: | 275 case OPERAND_TYPE_YMM: |
| 280 case OPERAND_YMM: | |
| 281 assert(FALSE); | 276 assert(FALSE); |
| 282 } | 277 } |
| 283 } else { | 278 } else { |
| 284 show_name_suffix = FALSE; | 279 show_name_suffix = FALSE; |
| 285 } | 280 } |
| 286 } else if ((instruction->operands[i].name == REG_IMM) || | 281 } else if ((instruction->operands[i].name == REG_IMM) || |
| 287 (instruction->operands[i].name == REG_IMM2) || | 282 (instruction->operands[i].name == REG_IMM2) || |
| 288 (instruction->operands[i].name == REG_RM) || | 283 (instruction->operands[i].name == REG_RM) || |
| 289 (instruction->operands[i].name == REG_PORT_DX) || | 284 (instruction->operands[i].name == REG_PORT_DX) || |
| 290 (instruction->operands[i].name == REG_ES_RDI) || | 285 (instruction->operands[i].name == REG_ES_RDI) || |
| 291 (instruction->operands[i].name == REG_DS_RSI)) { | 286 (instruction->operands[i].name == REG_DS_RSI)) { |
| 292 if (show_name_suffix) { | 287 if (show_name_suffix) { |
| 293 switch (instruction->operands[i].type) { | 288 switch (instruction->operands[i].type) { |
| 294 case OPERAND_SIZE_8_BIT: show_name_suffix = 'b'; break; | 289 case OPERAND_TYPE_8_BIT: show_name_suffix = 'b'; break; |
| 295 case OPERAND_SIZE_16_BIT: show_name_suffix = 'w'; break; | 290 case OPERAND_TYPE_16_BIT: show_name_suffix = 'w'; break; |
| 296 case OPERAND_SIZE_32_BIT: show_name_suffix = 'l'; break; | 291 case OPERAND_TYPE_32_BIT: show_name_suffix = 'l'; break; |
| 297 case OPERAND_SIZE_64_BIT: show_name_suffix = 'q'; break; | 292 case OPERAND_TYPE_64_BIT: show_name_suffix = 'q'; break; |
| 298 case OPERAND_FLOAT_SIZE_32_BIT: show_name_suffix = 's'; break; | 293 case OPERAND_TYPE_FLOAT_32_BIT: show_name_suffix = 's'; break; |
| 299 case OPERAND_FLOAT_SIZE_64_BIT: show_name_suffix = 'l'; break; | 294 case OPERAND_TYPE_FLOAT_64_BIT: show_name_suffix = 'l'; break; |
| 300 case OPERAND_FLOAT_SIZE_80_BIT:show_name_suffix = 't'; break; | 295 case OPERAND_TYPE_FLOAT_80_BIT:show_name_suffix = 't'; break; |
| 301 case OPERAND_X87_SIZE_32_BIT: show_name_suffix = 'l'; break; | 296 case OPERAND_TYPE_X87_32_BIT: show_name_suffix = 'l'; break; |
| 302 case OPERAND_X87_SIZE_64_BIT: show_name_suffix = 'L'; break; | 297 case OPERAND_TYPE_X87_64_BIT: show_name_suffix = 'L'; break; |
| 303 case OPERAND_SIZE_2_BIT: | 298 case OPERAND_TYPE_2_BIT: |
| 304 case OPERAND_X87_SIZE_16_BIT: | 299 case OPERAND_TYPE_X87_16_BIT: |
| 305 case OPERAND_X87_BCD: | 300 case OPERAND_TYPE_X87_BCD: |
| 306 case OPERAND_X87_ENV: | 301 case OPERAND_TYPE_X87_ENV: |
| 307 case OPERAND_X87_STATE: | 302 case OPERAND_TYPE_X87_STATE: |
| 308 case OPERAND_X87_MMX_MM_STATE: | 303 case OPERAND_TYPE_X87_MMX_XMM_STATE: |
| 309 case OPERAND_SIZE_128_BIT: | 304 case OPERAND_TYPE_128_BIT: |
| 310 case OPERAND_SIZE_256_BIT: | 305 case OPERAND_TYPE_256_BIT: |
| 311 case OPERAND_FAR_PTR: | 306 case OPERAND_TYPE_FAR_PTR: |
| 312 case OPERAND_MMX: | 307 case OPERAND_TYPE_MMX: |
| 313 case OPERAND_XMM: | 308 case OPERAND_TYPE_XMM: |
| 314 case OPERAND_YMM: | 309 case OPERAND_TYPE_YMM: |
| 315 case OPERAND_SELECTOR: show_name_suffix = FALSE; break; | 310 case OPERAND_TYPE_SELECTOR: show_name_suffix = FALSE; break; |
| 316 case OPERAND_FLOAT_SIZE_16_BIT: | 311 case OPERAND_TYPE_ST: |
| 317 case OPERAND_ST: | 312 case OPERAND_TYPE_SEGMENT_REGISTER: |
| 318 case OPERAND_SEGMENT_REGISTER: | 313 case OPERAND_TYPE_CONTROL_REGISTER: |
| 319 case OPERAND_CONTROL_REGISTER: | 314 case OPERAND_TYPE_DEBUG_REGISTER: |
| 320 case OPERAND_DEBUG_REGISTER: | |
| 321 assert(FALSE); | 315 assert(FALSE); |
| 322 } | 316 } |
| 323 } | 317 } |
| 324 } else { | 318 } else { |
| 325 /* "Empty" rex prefix (0x40) is used to select "sil"/"dil"/"spl"/"bpl". | 319 /* "Empty" rex prefix (0x40) is used to select "sil"/"dil"/"spl"/"bpl". |
| 326 */ | 320 */ |
| 327 if (instruction->operands[i].type == OPERAND_SIZE_8_BIT && | 321 if (instruction->operands[i].type == OPERAND_TYPE_8_BIT && |
| 328 instruction->operands[i].name <= REG_R15) { | 322 instruction->operands[i].name <= REG_R15) { |
| 329 empty_rex_prefix_ok = TRUE; | 323 empty_rex_prefix_ok = TRUE; |
| 330 } | 324 } |
| 331 /* First argument of "rcl"/"rcr"/"rol"/"ror"/"sar/""shl"/"shr" | 325 /* First argument of "rcl"/"rcr"/"rol"/"ror"/"sar/""shl"/"shr" |
| 332 can not be used to determine size of command. */ | 326 can not be used to determine size of command. */ |
| 333 if (((i != 1) || (strcmp(instruction_name, "rcl") && | 327 if (((i != 1) || (strcmp(instruction_name, "rcl") && |
| 334 strcmp(instruction_name, "rcr") && | 328 strcmp(instruction_name, "rcr") && |
| 335 strcmp(instruction_name, "rol") && | 329 strcmp(instruction_name, "rol") && |
| 336 strcmp(instruction_name, "ror") && | 330 strcmp(instruction_name, "ror") && |
| 337 strcmp(instruction_name, "sal") && | 331 strcmp(instruction_name, "sal") && |
| 338 strcmp(instruction_name, "sar") && | 332 strcmp(instruction_name, "sar") && |
| 339 strcmp(instruction_name, "shl") && | 333 strcmp(instruction_name, "shl") && |
| 340 strcmp(instruction_name, "shr"))) && | 334 strcmp(instruction_name, "shr"))) && |
| 341 /* Second argument of "crc32" can not be used to determine size of | 335 /* Second argument of "crc32" can not be used to determine size of |
| 342 command. */ | 336 command. */ |
| 343 ((i != 0) || strcmp(instruction_name, "crc32"))) { | 337 ((i != 0) || strcmp(instruction_name, "crc32"))) { |
| 344 show_name_suffix = FALSE; | 338 show_name_suffix = FALSE; |
| 345 } | 339 } |
| 346 /* First argument of "crc32" can be used for that but objdump uses | 340 /* First argument of "crc32" can be used for that but objdump uses |
| 347 suffix anyway. */ | 341 suffix anyway. */ |
| 348 if ((i == 1) && (!strcmp(instruction_name, "crc32"))) { | 342 if ((i == 1) && (!strcmp(instruction_name, "crc32"))) { |
| 349 switch (instruction->operands[i].type) { | 343 switch (instruction->operands[i].type) { |
| 350 case OPERAND_SIZE_8_BIT: show_name_suffix = 'b'; break; | 344 case OPERAND_TYPE_8_BIT: show_name_suffix = 'b'; break; |
| 351 case OPERAND_SIZE_16_BIT: show_name_suffix = 'w'; break; | 345 case OPERAND_TYPE_16_BIT: show_name_suffix = 'w'; break; |
| 352 case OPERAND_SIZE_32_BIT: show_name_suffix = 'l'; break; | 346 case OPERAND_TYPE_32_BIT: show_name_suffix = 'l'; break; |
| 353 case OPERAND_SIZE_64_BIT: show_name_suffix = 'q'; break; | 347 case OPERAND_TYPE_64_BIT: show_name_suffix = 'q'; break; |
| 354 case OPERAND_SIZE_2_BIT: | 348 case OPERAND_TYPE_2_BIT: |
| 355 case OPERAND_SIZE_128_BIT: | 349 case OPERAND_TYPE_128_BIT: |
| 356 case OPERAND_SIZE_256_BIT: | 350 case OPERAND_TYPE_256_BIT: |
| 357 case OPERAND_FLOAT_SIZE_16_BIT: | 351 case OPERAND_TYPE_FLOAT_32_BIT: |
| 358 case OPERAND_FLOAT_SIZE_32_BIT: | 352 case OPERAND_TYPE_FLOAT_64_BIT: |
| 359 case OPERAND_FLOAT_SIZE_64_BIT: | 353 case OPERAND_TYPE_FLOAT_80_BIT: |
| 360 case OPERAND_FLOAT_SIZE_80_BIT: | 354 case OPERAND_TYPE_X87_16_BIT: |
| 361 case OPERAND_X87_SIZE_16_BIT: | 355 case OPERAND_TYPE_X87_32_BIT: |
| 362 case OPERAND_X87_SIZE_32_BIT: | 356 case OPERAND_TYPE_X87_64_BIT: |
| 363 case OPERAND_X87_SIZE_64_BIT: | 357 case OPERAND_TYPE_X87_BCD: |
| 364 case OPERAND_X87_BCD: | 358 case OPERAND_TYPE_X87_ENV: |
| 365 case OPERAND_X87_ENV: | 359 case OPERAND_TYPE_X87_STATE: |
| 366 case OPERAND_X87_STATE: | 360 case OPERAND_TYPE_X87_MMX_XMM_STATE: |
| 367 case OPERAND_X87_MMX_MM_STATE: | 361 case OPERAND_TYPE_ST: |
| 368 case OPERAND_ST: | 362 case OPERAND_TYPE_SELECTOR: |
| 369 case OPERAND_SELECTOR: | 363 case OPERAND_TYPE_FAR_PTR: |
| 370 case OPERAND_FAR_PTR: | 364 case OPERAND_TYPE_SEGMENT_REGISTER: |
| 371 case OPERAND_SEGMENT_REGISTER: | 365 case OPERAND_TYPE_CONTROL_REGISTER: |
| 372 case OPERAND_CONTROL_REGISTER: | 366 case OPERAND_TYPE_DEBUG_REGISTER: |
| 373 case OPERAND_DEBUG_REGISTER: | 367 case OPERAND_TYPE_MMX: |
| 374 case OPERAND_MMX: | 368 case OPERAND_TYPE_XMM: |
| 375 case OPERAND_XMM: | 369 case OPERAND_TYPE_YMM: |
| 376 case OPERAND_YMM: | |
| 377 assert(FALSE); | 370 assert(FALSE); |
| 378 } | 371 } |
| 379 } | 372 } |
| 380 } | 373 } |
| 381 if ((instruction->operands[i].name >= REG_R8) && | 374 if ((instruction->operands[i].name >= REG_R8) && |
| 382 (instruction->operands[i].name <= REG_R15) && | 375 (instruction->operands[i].name <= REG_R15) && |
| 383 (instruction->operands[i].type != OPERAND_MMX)) { | 376 (instruction->operands[i].type != OPERAND_TYPE_MMX)) { |
| 384 if (!((struct DecodeState *)userdata)->ia32_mode) { | 377 if (!((struct DecodeState *)userdata)->ia32_mode) { |
| 385 ++rex_bits; | 378 ++rex_bits; |
| 386 /* HACK: objdump mistakenly allows "lock" with "mov %crX,%rXX" only in | 379 /* HACK: objdump mistakenly allows "lock" with "mov %crX,%rXX" only in |
| 387 32bit mode. It's perfectly valid in 64bit mode, too, so instead of | 380 32bit mode. It's perfectly valid in 64bit mode, too, so instead of |
| 388 changing the decoder we fix it here. */ | 381 changing the decoder we fix it here. */ |
| 389 if (instruction->operands[i].type == OPERAND_CONTROL_REGISTER) { | 382 if (instruction->operands[i].type == OPERAND_TYPE_CONTROL_REGISTER) { |
| 390 if ((*begin == 0xf0) && !(instruction->prefix.lock)) { | 383 if ((*begin == 0xf0) && !(instruction->prefix.lock)) { |
| 391 print_name("lock "); | 384 print_name("lock "); |
| 392 if (!(rex_prefix & 0x04)) { | 385 if (!(rex_prefix & 0x04)) { |
| 393 instruction->operands[i].name -= 8; | 386 instruction->operands[i].name -= 8; |
| 394 --rex_bits; | 387 --rex_bits; |
| 395 } | 388 } |
| 396 } | 389 } |
| 397 } | 390 } |
| 398 } | 391 } |
| 399 } else if (instruction->operands[i].name == REG_RM) { | 392 } else if (instruction->operands[i].name == REG_RM) { |
| 400 if ((rm_base >= REG_R8) && | 393 if ((rm_base >= REG_R8) && |
| 401 (rm_base <= REG_R15)) { | 394 (rm_base <= REG_R15)) { |
| 402 ++rex_bits; | 395 ++rex_bits; |
| 403 } else if ((rm_base == NO_REG) || | 396 } else if ((rm_base == NO_REG) || |
| 404 (rm_base == REG_RIP)) { | 397 (rm_base == REG_RIP)) { |
| 405 if (strcmp(instruction_name, "movabs")) | 398 if (strcmp(instruction_name, "movabs")) |
| 406 ++maybe_rex_bits; | 399 ++maybe_rex_bits; |
| 407 } | 400 } |
| 408 if ((rm_index >= REG_R8) && | 401 if ((rm_index >= REG_R8) && |
| 409 (rm_index <= REG_R15)) { | 402 (rm_index <= REG_R15)) { |
| 410 ++rex_bits; | 403 ++rex_bits; |
| 411 } | 404 } |
| 412 } | 405 } |
| 413 if ((instruction->operands[i].type == OPERAND_SIZE_64_BIT) && | 406 if ((instruction->operands[i].type == OPERAND_TYPE_64_BIT) && |
| 414 !rexw_counted) { | 407 !rexw_counted) { |
| 415 if (strcmp(instruction_name, "callq") && | 408 if (strcmp(instruction_name, "callq") && |
| 416 strcmp(instruction_name, "cmpxchg8b") && | 409 strcmp(instruction_name, "cmpxchg8b") && |
| 417 strcmp(instruction_name, "cvtpi2ps") && | 410 strcmp(instruction_name, "cvtpi2ps") && |
| 418 strcmp(instruction_name, "cvtpi2pd") && | 411 strcmp(instruction_name, "cvtpi2pd") && |
| 419 (strcmp(instruction_name, "extractps") || | 412 (strcmp(instruction_name, "extractps") || |
| 420 instruction->operands[i].name != REG_RM) && | 413 instruction->operands[i].name != REG_RM) && |
| 421 strcmp(instruction_name, "jmpq") && | 414 strcmp(instruction_name, "jmpq") && |
| 422 strcmp(instruction_name, "monitor") && | 415 strcmp(instruction_name, "monitor") && |
| 423 strcmp(instruction_name, "movntq") && | 416 strcmp(instruction_name, "movntq") && |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 strcmp(instruction_name, "punpcklqdq") && | 536 strcmp(instruction_name, "punpcklqdq") && |
| 544 strcmp(instruction_name, "punpcklwd") && | 537 strcmp(instruction_name, "punpcklwd") && |
| 545 strcmp(instruction_name, "push") && | 538 strcmp(instruction_name, "push") && |
| 546 strcmp(instruction_name, "pxor") && | 539 strcmp(instruction_name, "pxor") && |
| 547 strcmp(instruction_name, "unpckhpd") && | 540 strcmp(instruction_name, "unpckhpd") && |
| 548 strcmp(instruction_name, "unpcklpd")) { | 541 strcmp(instruction_name, "unpcklpd")) { |
| 549 ++rex_bits; | 542 ++rex_bits; |
| 550 rexw_counted = TRUE; | 543 rexw_counted = TRUE; |
| 551 } | 544 } |
| 552 if ((operands_count == 2) && | 545 if ((operands_count == 2) && |
| 553 ((instruction->operands[1-i].type == OPERAND_CONTROL_REGISTER) || | 546 ((instruction->operands[1-i].type == OPERAND_TYPE_CONTROL_REGISTER) || |
| 554 (instruction->operands[1-i].type == OPERAND_DEBUG_REGISTER))) { | 547 (instruction->operands[1-i].type == OPERAND_TYPE_DEBUG_REGISTER))) { |
| 555 --rex_bits; | 548 --rex_bits; |
| 556 } | 549 } |
| 557 } | 550 } |
| 558 if ((instruction->operands[i].type == OPERAND_SIZE_128_BIT) && | 551 if ((instruction->operands[i].type == OPERAND_TYPE_128_BIT) && |
| 559 !rexw_counted) { | 552 !rexw_counted) { |
| 560 if (!strcmp(instruction_name, "cmpxchg16b")) { | 553 if (!strcmp(instruction_name, "cmpxchg16b")) { |
| 561 ++rex_bits; | 554 ++rex_bits; |
| 562 rexw_counted = TRUE; | 555 rexw_counted = TRUE; |
| 563 } | 556 } |
| 564 } | 557 } |
| 565 } | 558 } |
| 566 } | 559 } |
| 567 if ((!strcmp(instruction_name, "cvtsi2sd") || | 560 if ((!strcmp(instruction_name, "cvtsi2sd") || |
| 568 !strcmp(instruction_name, "cvtsi2ss")) && | 561 !strcmp(instruction_name, "cvtsi2ss")) && |
| 569 instruction->operands[1].name == REG_RM) { | 562 instruction->operands[1].name == REG_RM) { |
| 570 if (instruction->operands[1].type == OPERAND_SIZE_32_BIT) { | 563 if (instruction->operands[1].type == OPERAND_TYPE_32_BIT) { |
| 571 show_name_suffix = 'l'; | 564 show_name_suffix = 'l'; |
| 572 } else { | 565 } else { |
| 573 show_name_suffix = 'q'; | 566 show_name_suffix = 'q'; |
| 574 } | 567 } |
| 575 } | 568 } |
| 576 if ((!strcmp(instruction_name, "vcvtpd2dq") || | 569 if ((!strcmp(instruction_name, "vcvtpd2dq") || |
| 577 !strcmp(instruction_name, "vcvtpd2ps") || | 570 !strcmp(instruction_name, "vcvtpd2ps") || |
| 578 !strcmp(instruction_name, "vcvttpd2dq") || | 571 !strcmp(instruction_name, "vcvttpd2dq") || |
| 579 !strcmp(instruction_name, "vcvttpd2ps")) && | 572 !strcmp(instruction_name, "vcvttpd2ps")) && |
| 580 instruction->operands[1].name == REG_RM) { | 573 instruction->operands[1].name == REG_RM) { |
| 581 if (instruction->operands[1].type == OPERAND_SIZE_128_BIT) { | 574 if (instruction->operands[1].type == OPERAND_TYPE_128_BIT) { |
| 582 show_name_suffix = 'x'; | 575 show_name_suffix = 'x'; |
| 583 } else { | 576 } else { |
| 584 show_name_suffix = 'y'; | 577 show_name_suffix = 'y'; |
| 585 } | 578 } |
| 586 } | 579 } |
| 587 if ((!strcmp(instruction_name, "vcvtsi2sd") || | 580 if ((!strcmp(instruction_name, "vcvtsi2sd") || |
| 588 !strcmp(instruction_name, "vcvtsi2ss")) && | 581 !strcmp(instruction_name, "vcvtsi2ss")) && |
| 589 instruction->operands[2].name == REG_RM) { | 582 instruction->operands[2].name == REG_RM) { |
| 590 if (instruction->operands[2].type == OPERAND_SIZE_32_BIT) { | 583 if (instruction->operands[2].type == OPERAND_TYPE_32_BIT) { |
| 591 show_name_suffix = 'l'; | 584 show_name_suffix = 'l'; |
| 592 } else { | 585 } else { |
| 593 show_name_suffix = 'q'; | 586 show_name_suffix = 'q'; |
| 594 } | 587 } |
| 595 } | 588 } |
| 596 if (instruction->prefix.lock && (begin[0] == 0xf0)) { | 589 if (instruction->prefix.lock && (begin[0] == 0xf0)) { |
| 597 print_name("lock "); | 590 print_name("lock "); |
| 598 } | 591 } |
| 599 if (instruction->prefix.repnz && (begin[0] == 0xf2)) { | 592 if (instruction->prefix.repnz && (begin[0] == 0xf2)) { |
| 600 print_name("repnz "); | 593 print_name("repnz "); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 /* "callq","cmpxchg8b"/"jmpq" already include suffix in the nanme. */ | 790 /* "callq","cmpxchg8b"/"jmpq" already include suffix in the nanme. */ |
| 798 if ((!strcmp(instruction_name, "callq")) || | 791 if ((!strcmp(instruction_name, "callq")) || |
| 799 (!strcmp(instruction_name, "cmpxchg8b")) || | 792 (!strcmp(instruction_name, "cmpxchg8b")) || |
| 800 (!strcmp(instruction_name, "jmpq"))) { | 793 (!strcmp(instruction_name, "jmpq"))) { |
| 801 show_name_suffix = FALSE; | 794 show_name_suffix = FALSE; |
| 802 } | 795 } |
| 803 } | 796 } |
| 804 if (rex_prefix & 0x08) { | 797 if (rex_prefix & 0x08) { |
| 805 /* rex.W is not shown for relative jumps with rel32 operand, but are | 798 /* rex.W is not shown for relative jumps with rel32 operand, but are |
| 806 shown for relative jumps with rel8 operands. */ | 799 shown for relative jumps with rel8 operands. */ |
| 807 if ((instruction->operands[0].type == OPERAND_SIZE_32_BIT) && | 800 if ((instruction->operands[0].type == OPERAND_TYPE_32_BIT) && |
| 808 (!strcmp(instruction_name, "ja") || | 801 (!strcmp(instruction_name, "ja") || |
| 809 !strcmp(instruction_name, "jae") || | 802 !strcmp(instruction_name, "jae") || |
| 810 !strcmp(instruction_name, "jb") || | 803 !strcmp(instruction_name, "jb") || |
| 811 !strcmp(instruction_name, "jbe") || | 804 !strcmp(instruction_name, "jbe") || |
| 812 !strcmp(instruction_name, "je") || | 805 !strcmp(instruction_name, "je") || |
| 813 !strcmp(instruction_name, "jg") || | 806 !strcmp(instruction_name, "jg") || |
| 814 !strcmp(instruction_name, "jge") || | 807 !strcmp(instruction_name, "jge") || |
| 815 !strcmp(instruction_name, "jl") || | 808 !strcmp(instruction_name, "jl") || |
| 816 !strcmp(instruction_name, "jle") || | 809 !strcmp(instruction_name, "jle") || |
| 817 !strcmp(instruction_name, "jne") || | 810 !strcmp(instruction_name, "jne") || |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 if (show_name_suffix) { | 875 if (show_name_suffix) { |
| 883 if (show_name_suffix == 'L') { | 876 if (show_name_suffix == 'L') { |
| 884 print_name("ll"); | 877 print_name("ll"); |
| 885 } else { | 878 } else { |
| 886 printf("%c", show_name_suffix); | 879 printf("%c", show_name_suffix); |
| 887 ++shown_name; | 880 ++shown_name; |
| 888 } | 881 } |
| 889 } | 882 } |
| 890 if (!strcmp(instruction_name, "mov")) { | 883 if (!strcmp(instruction_name, "mov")) { |
| 891 if ((instruction->operands[1].name == REG_IMM) && | 884 if ((instruction->operands[1].name == REG_IMM) && |
| 892 (instruction->operands[1].type == OPERAND_SIZE_64_BIT)) { | 885 (instruction->operands[1].type == OPERAND_TYPE_64_BIT)) { |
| 893 print_name("abs"); | 886 print_name("abs"); |
| 894 } | 887 } |
| 895 } | 888 } |
| 896 { | 889 { |
| 897 size_t i; | 890 size_t i; |
| 898 /* Print branch hint suffixes for conditional jump instructions (Jcc). */ | 891 /* Print branch hint suffixes for conditional jump instructions (Jcc). */ |
| 899 const char* jcc_jumps[] = { | 892 const char* jcc_jumps[] = { |
| 900 "ja", "jae", "jbe", "jb", "je", "jg", "jge", "jle", | 893 "ja", "jae", "jbe", "jb", "je", "jg", "jge", "jle", |
| 901 "jl", "jne", "jno", "jnp", "jns", "jo", "jp", "js", | 894 "jl", "jne", "jno", "jnp", "jns", "jo", "jp", "js", |
| 902 "jecxz", "jrcxz", "loop", "loope", "loopne", NULL}; | 895 "jecxz", "jrcxz", "loop", "loope", "loopne", NULL}; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 980 (!strcmp(instruction_name, "ljmpq")) || | 973 (!strcmp(instruction_name, "ljmpq")) || |
| 981 (!strcmp(instruction_name, "lcallw")) || | 974 (!strcmp(instruction_name, "lcallw")) || |
| 982 (!strcmp(instruction_name, "lcallq"))) { | 975 (!strcmp(instruction_name, "lcallq"))) { |
| 983 printf("*"); | 976 printf("*"); |
| 984 } | 977 } |
| 985 /* Dirty hack: both AMD manual and Intel manual agree that mov from general | 978 /* Dirty hack: both AMD manual and Intel manual agree that mov from general |
| 986 purpose register to segment register has signature "mov Ew Sw", but | 979 purpose register to segment register has signature "mov Ew Sw", but |
| 987 objdump insist on 32bit/64 bit. This is clearly error in objdump so we | 980 objdump insist on 32bit/64 bit. This is clearly error in objdump so we |
| 988 fix it here and not in decoder. */ | 981 fix it here and not in decoder. */ |
| 989 if ((begin[0] >= 0x48) && (begin[0] <= 0x4f) && (begin[1] == 0x8e) && | 982 if ((begin[0] >= 0x48) && (begin[0] <= 0x4f) && (begin[1] == 0x8e) && |
| 990 (instruction->operands[i].type == OPERAND_SIZE_16_BIT)) { | 983 (instruction->operands[i].type == OPERAND_TYPE_16_BIT)) { |
| 991 operand_type = OPERAND_SIZE_64_BIT; | 984 operand_type = OPERAND_TYPE_64_BIT; |
| 992 } else if (((begin[0] == 0x8e) || | 985 } else if (((begin[0] == 0x8e) || |
| 993 ((begin[0] >= 0x40) && (begin[0] <= 0x4f) && (begin[1] == 0x8e))) && | 986 ((begin[0] >= 0x40) && (begin[0] <= 0x4f) && (begin[1] == 0x8e))) && |
| 994 (instruction->operands[i].type == OPERAND_SIZE_16_BIT)) { | 987 (instruction->operands[i].type == OPERAND_TYPE_16_BIT)) { |
| 995 operand_type = OPERAND_SIZE_32_BIT; | 988 operand_type = OPERAND_TYPE_32_BIT; |
| 996 } else { | 989 } else { |
| 997 operand_type = instruction->operands[i].type; | 990 operand_type = instruction->operands[i].type; |
| 998 } | 991 } |
| 999 switch (instruction->operands[i].name) { | 992 switch (instruction->operands[i].name) { |
| 1000 case REG_RAX: switch (operand_type) { | 993 case REG_RAX: switch (operand_type) { |
| 1001 case OPERAND_SIZE_8_BIT: printf("%%al"); break; | 994 case OPERAND_TYPE_8_BIT: printf("%%al"); break; |
| 1002 case OPERAND_SIZE_16_BIT: printf("%%ax"); break; | 995 case OPERAND_TYPE_16_BIT: printf("%%ax"); break; |
| 1003 case OPERAND_SIZE_32_BIT: printf("%%eax"); break; | 996 case OPERAND_TYPE_32_BIT: printf("%%eax"); break; |
| 1004 case OPERAND_SIZE_64_BIT: printf("%%rax"); break; | 997 case OPERAND_TYPE_64_BIT: printf("%%rax"); break; |
| 1005 case OPERAND_ST: printf("%%st(0)"); break; | 998 case OPERAND_TYPE_ST: printf("%%st(0)"); break; |
| 1006 case OPERAND_MMX: printf("%%mm0"); break; | 999 case OPERAND_TYPE_MMX: printf("%%mm0"); break; |
| 1007 case OPERAND_FLOAT_SIZE_32_BIT: | 1000 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1008 case OPERAND_FLOAT_SIZE_64_BIT: | 1001 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1009 case OPERAND_SIZE_128_BIT: | 1002 case OPERAND_TYPE_128_BIT: |
| 1010 case OPERAND_XMM: printf("%%xmm0"); break; | 1003 case OPERAND_TYPE_XMM: printf("%%xmm0"); break; |
| 1011 case OPERAND_SIZE_256_BIT: | 1004 case OPERAND_TYPE_256_BIT: |
| 1012 case OPERAND_YMM: printf("%%ymm0"); break; | 1005 case OPERAND_TYPE_YMM: printf("%%ymm0"); break; |
| 1013 case OPERAND_SEGMENT_REGISTER: printf("%%es"); break; | 1006 case OPERAND_TYPE_SEGMENT_REGISTER: printf("%%es"); break; |
| 1014 case OPERAND_CONTROL_REGISTER: printf("%%cr0"); break; | 1007 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr0"); break; |
| 1015 case OPERAND_DEBUG_REGISTER: printf("%%db0"); break; | 1008 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db0"); break; |
| 1016 default: assert(FALSE); | 1009 default: assert(FALSE); |
| 1017 } | 1010 } |
| 1018 break; | 1011 break; |
| 1019 case REG_RCX: switch (operand_type) { | 1012 case REG_RCX: switch (operand_type) { |
| 1020 case OPERAND_SIZE_8_BIT: printf("%%cl"); break; | 1013 case OPERAND_TYPE_8_BIT: printf("%%cl"); break; |
| 1021 case OPERAND_SIZE_16_BIT: printf("%%cx"); break; | 1014 case OPERAND_TYPE_16_BIT: printf("%%cx"); break; |
| 1022 case OPERAND_SIZE_32_BIT: printf("%%ecx"); break; | 1015 case OPERAND_TYPE_32_BIT: printf("%%ecx"); break; |
| 1023 case OPERAND_SIZE_64_BIT: printf("%%rcx"); break; | 1016 case OPERAND_TYPE_64_BIT: printf("%%rcx"); break; |
| 1024 case OPERAND_ST: printf("%%st(1)"); break; | 1017 case OPERAND_TYPE_ST: printf("%%st(1)"); break; |
| 1025 case OPERAND_MMX: printf("%%mm1"); break; | 1018 case OPERAND_TYPE_MMX: printf("%%mm1"); break; |
| 1026 case OPERAND_FLOAT_SIZE_32_BIT: | 1019 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1027 case OPERAND_FLOAT_SIZE_64_BIT: | 1020 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1028 case OPERAND_SIZE_128_BIT: | 1021 case OPERAND_TYPE_128_BIT: |
| 1029 case OPERAND_XMM: printf("%%xmm1"); break; | 1022 case OPERAND_TYPE_XMM: printf("%%xmm1"); break; |
| 1030 case OPERAND_SIZE_256_BIT: | 1023 case OPERAND_TYPE_256_BIT: |
| 1031 case OPERAND_YMM: printf("%%ymm1"); break; | 1024 case OPERAND_TYPE_YMM: printf("%%ymm1"); break; |
| 1032 case OPERAND_SEGMENT_REGISTER: printf("%%cs"); break; | 1025 case OPERAND_TYPE_SEGMENT_REGISTER: printf("%%cs"); break; |
| 1033 case OPERAND_CONTROL_REGISTER: printf("%%cr1"); break; | 1026 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr1"); break; |
| 1034 case OPERAND_DEBUG_REGISTER: printf("%%db1"); break; | 1027 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db1"); break; |
| 1035 default: assert(FALSE); | 1028 default: assert(FALSE); |
| 1036 } | 1029 } |
| 1037 break; | 1030 break; |
| 1038 case REG_RDX: switch (operand_type) { | 1031 case REG_RDX: switch (operand_type) { |
| 1039 case OPERAND_SIZE_8_BIT: printf("%%dl"); break; | 1032 case OPERAND_TYPE_8_BIT: printf("%%dl"); break; |
| 1040 case OPERAND_SIZE_16_BIT: printf("%%dx"); break; | 1033 case OPERAND_TYPE_16_BIT: printf("%%dx"); break; |
| 1041 case OPERAND_SIZE_32_BIT: printf("%%edx"); break; | 1034 case OPERAND_TYPE_32_BIT: printf("%%edx"); break; |
| 1042 case OPERAND_SIZE_64_BIT: printf("%%rdx"); break; | 1035 case OPERAND_TYPE_64_BIT: printf("%%rdx"); break; |
| 1043 case OPERAND_ST: printf("%%st(2)"); break; | 1036 case OPERAND_TYPE_ST: printf("%%st(2)"); break; |
| 1044 case OPERAND_MMX: printf("%%mm2"); break; | 1037 case OPERAND_TYPE_MMX: printf("%%mm2"); break; |
| 1045 case OPERAND_FLOAT_SIZE_32_BIT: | 1038 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1046 case OPERAND_FLOAT_SIZE_64_BIT: | 1039 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1047 case OPERAND_SIZE_128_BIT: | 1040 case OPERAND_TYPE_128_BIT: |
| 1048 case OPERAND_XMM: printf("%%xmm2"); break; | 1041 case OPERAND_TYPE_XMM: printf("%%xmm2"); break; |
| 1049 case OPERAND_SIZE_256_BIT: | 1042 case OPERAND_TYPE_256_BIT: |
| 1050 case OPERAND_YMM: printf("%%ymm2"); break; | 1043 case OPERAND_TYPE_YMM: printf("%%ymm2"); break; |
| 1051 case OPERAND_SEGMENT_REGISTER: printf("%%ss"); break; | 1044 case OPERAND_TYPE_SEGMENT_REGISTER: printf("%%ss"); break; |
| 1052 case OPERAND_CONTROL_REGISTER: printf("%%cr2"); break; | 1045 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr2"); break; |
| 1053 case OPERAND_DEBUG_REGISTER: printf("%%db2"); break; | 1046 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db2"); break; |
| 1054 default: assert(FALSE); | 1047 default: assert(FALSE); |
| 1055 } | 1048 } |
| 1056 break; | 1049 break; |
| 1057 case REG_RBX: switch (operand_type) { | 1050 case REG_RBX: switch (operand_type) { |
| 1058 case OPERAND_SIZE_8_BIT: printf("%%bl"); break; | 1051 case OPERAND_TYPE_8_BIT: printf("%%bl"); break; |
| 1059 case OPERAND_SIZE_16_BIT: printf("%%bx"); break; | 1052 case OPERAND_TYPE_16_BIT: printf("%%bx"); break; |
| 1060 case OPERAND_SIZE_32_BIT: printf("%%ebx"); break; | 1053 case OPERAND_TYPE_32_BIT: printf("%%ebx"); break; |
| 1061 case OPERAND_SIZE_64_BIT: printf("%%rbx"); break; | 1054 case OPERAND_TYPE_64_BIT: printf("%%rbx"); break; |
| 1062 case OPERAND_ST: printf("%%st(3)"); break; | 1055 case OPERAND_TYPE_ST: printf("%%st(3)"); break; |
| 1063 case OPERAND_MMX: printf("%%mm3"); break; | 1056 case OPERAND_TYPE_MMX: printf("%%mm3"); break; |
| 1064 case OPERAND_FLOAT_SIZE_32_BIT: | 1057 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1065 case OPERAND_FLOAT_SIZE_64_BIT: | 1058 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1066 case OPERAND_SIZE_128_BIT: | 1059 case OPERAND_TYPE_128_BIT: |
| 1067 case OPERAND_XMM: printf("%%xmm3"); break; | 1060 case OPERAND_TYPE_XMM: printf("%%xmm3"); break; |
| 1068 case OPERAND_SIZE_256_BIT: | 1061 case OPERAND_TYPE_256_BIT: |
| 1069 case OPERAND_YMM: printf("%%ymm3"); break; | 1062 case OPERAND_TYPE_YMM: printf("%%ymm3"); break; |
| 1070 case OPERAND_SEGMENT_REGISTER: printf("%%ds"); break; | 1063 case OPERAND_TYPE_SEGMENT_REGISTER: printf("%%ds"); break; |
| 1071 case OPERAND_CONTROL_REGISTER: printf("%%cr3"); break; | 1064 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr3"); break; |
| 1072 case OPERAND_DEBUG_REGISTER: printf("%%db3"); break; | 1065 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db3"); break; |
| 1073 default: assert(FALSE); | 1066 default: assert(FALSE); |
| 1074 } | 1067 } |
| 1075 break; | 1068 break; |
| 1076 case REG_RSP: switch (operand_type) { | 1069 case REG_RSP: switch (operand_type) { |
| 1077 case OPERAND_SIZE_8_BIT: if (rex_prefix) | 1070 case OPERAND_TYPE_8_BIT: if (rex_prefix) |
| 1078 printf("%%spl"); | 1071 printf("%%spl"); |
| 1079 else | 1072 else |
| 1080 printf("%%ah"); | 1073 printf("%%ah"); |
| 1081 break; | 1074 break; |
| 1082 case OPERAND_SIZE_16_BIT: printf("%%sp"); break; | 1075 case OPERAND_TYPE_16_BIT: printf("%%sp"); break; |
| 1083 case OPERAND_SIZE_32_BIT: printf("%%esp"); break; | 1076 case OPERAND_TYPE_32_BIT: printf("%%esp"); break; |
| 1084 case OPERAND_SIZE_64_BIT: printf("%%rsp"); break; | 1077 case OPERAND_TYPE_64_BIT: printf("%%rsp"); break; |
| 1085 case OPERAND_ST: printf("%%st(4)"); break; | 1078 case OPERAND_TYPE_ST: printf("%%st(4)"); break; |
| 1086 case OPERAND_MMX: printf("%%mm4"); break; | 1079 case OPERAND_TYPE_MMX: printf("%%mm4"); break; |
| 1087 case OPERAND_FLOAT_SIZE_32_BIT: | 1080 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1088 case OPERAND_FLOAT_SIZE_64_BIT: | 1081 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1089 case OPERAND_SIZE_128_BIT: | 1082 case OPERAND_TYPE_128_BIT: |
| 1090 case OPERAND_XMM: printf("%%xmm4"); break; | 1083 case OPERAND_TYPE_XMM: printf("%%xmm4"); break; |
| 1091 case OPERAND_SIZE_256_BIT: | 1084 case OPERAND_TYPE_256_BIT: |
| 1092 case OPERAND_YMM: printf("%%ymm4"); break; | 1085 case OPERAND_TYPE_YMM: printf("%%ymm4"); break; |
| 1093 case OPERAND_SEGMENT_REGISTER: printf("%%fs"); break; | 1086 case OPERAND_TYPE_SEGMENT_REGISTER: printf("%%fs"); break; |
| 1094 case OPERAND_CONTROL_REGISTER: printf("%%cr4"); break; | 1087 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr4"); break; |
| 1095 case OPERAND_DEBUG_REGISTER: printf("%%db4"); break; | 1088 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db4"); break; |
| 1096 default: assert(FALSE); | 1089 default: assert(FALSE); |
| 1097 } | 1090 } |
| 1098 break; | 1091 break; |
| 1099 case REG_RBP: switch (operand_type) { | 1092 case REG_RBP: switch (operand_type) { |
| 1100 case OPERAND_SIZE_8_BIT: if (rex_prefix) | 1093 case OPERAND_TYPE_8_BIT: if (rex_prefix) |
| 1101 printf("%%bpl"); | 1094 printf("%%bpl"); |
| 1102 else | 1095 else |
| 1103 printf("%%ch"); | 1096 printf("%%ch"); |
| 1104 break; | 1097 break; |
| 1105 case OPERAND_SIZE_16_BIT: printf("%%bp"); break; | 1098 case OPERAND_TYPE_16_BIT: printf("%%bp"); break; |
| 1106 case OPERAND_SIZE_32_BIT: printf("%%ebp"); break; | 1099 case OPERAND_TYPE_32_BIT: printf("%%ebp"); break; |
| 1107 case OPERAND_SIZE_64_BIT: printf("%%rbp"); break; | 1100 case OPERAND_TYPE_64_BIT: printf("%%rbp"); break; |
| 1108 case OPERAND_ST: printf("%%st(5)"); break; | 1101 case OPERAND_TYPE_ST: printf("%%st(5)"); break; |
| 1109 case OPERAND_MMX: printf("%%mm5"); break; | 1102 case OPERAND_TYPE_MMX: printf("%%mm5"); break; |
| 1110 case OPERAND_FLOAT_SIZE_32_BIT: | 1103 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1111 case OPERAND_FLOAT_SIZE_64_BIT: | 1104 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1112 case OPERAND_SIZE_128_BIT: | 1105 case OPERAND_TYPE_128_BIT: |
| 1113 case OPERAND_XMM: printf("%%xmm5"); break; | 1106 case OPERAND_TYPE_XMM: printf("%%xmm5"); break; |
| 1114 case OPERAND_SIZE_256_BIT: | 1107 case OPERAND_TYPE_256_BIT: |
| 1115 case OPERAND_YMM: printf("%%ymm5"); break; | 1108 case OPERAND_TYPE_YMM: printf("%%ymm5"); break; |
| 1116 case OPERAND_SEGMENT_REGISTER: printf("%%gs"); break; | 1109 case OPERAND_TYPE_SEGMENT_REGISTER: printf("%%gs"); break; |
| 1117 case OPERAND_CONTROL_REGISTER: printf("%%cr5"); break; | 1110 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr5"); break; |
| 1118 case OPERAND_DEBUG_REGISTER: printf("%%db5"); break; | 1111 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db5"); break; |
| 1119 default: assert(FALSE); | 1112 default: assert(FALSE); |
| 1120 } | 1113 } |
| 1121 break; | 1114 break; |
| 1122 case REG_RSI: switch (operand_type) { | 1115 case REG_RSI: switch (operand_type) { |
| 1123 case OPERAND_SIZE_8_BIT: if (rex_prefix) | 1116 case OPERAND_TYPE_8_BIT: if (rex_prefix) |
| 1124 printf("%%sil"); | 1117 printf("%%sil"); |
| 1125 else | 1118 else |
| 1126 printf("%%dh"); | 1119 printf("%%dh"); |
| 1127 break; | 1120 break; |
| 1128 case OPERAND_SIZE_16_BIT: printf("%%si"); break; | 1121 case OPERAND_TYPE_16_BIT: printf("%%si"); break; |
| 1129 case OPERAND_SIZE_32_BIT: printf("%%esi"); break; | 1122 case OPERAND_TYPE_32_BIT: printf("%%esi"); break; |
| 1130 case OPERAND_SIZE_64_BIT: printf("%%rsi"); break; | 1123 case OPERAND_TYPE_64_BIT: printf("%%rsi"); break; |
| 1131 case OPERAND_ST: printf("%%st(6)"); break; | 1124 case OPERAND_TYPE_ST: printf("%%st(6)"); break; |
| 1132 case OPERAND_MMX: printf("%%mm6"); break; | 1125 case OPERAND_TYPE_MMX: printf("%%mm6"); break; |
| 1133 case OPERAND_FLOAT_SIZE_32_BIT: | 1126 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1134 case OPERAND_FLOAT_SIZE_64_BIT: | 1127 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1135 case OPERAND_SIZE_128_BIT: | 1128 case OPERAND_TYPE_128_BIT: |
| 1136 case OPERAND_XMM: printf("%%xmm6"); break; | 1129 case OPERAND_TYPE_XMM: printf("%%xmm6"); break; |
| 1137 case OPERAND_SIZE_256_BIT: | 1130 case OPERAND_TYPE_256_BIT: |
| 1138 case OPERAND_YMM: printf("%%ymm6"); break; | 1131 case OPERAND_TYPE_YMM: printf("%%ymm6"); break; |
| 1139 case OPERAND_CONTROL_REGISTER: printf("%%cr6"); break; | 1132 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr6"); break; |
| 1140 case OPERAND_DEBUG_REGISTER: printf("%%db6"); break; | 1133 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db6"); break; |
| 1141 default: assert(FALSE); | 1134 default: assert(FALSE); |
| 1142 } | 1135 } |
| 1143 break; | 1136 break; |
| 1144 case REG_RDI: switch (operand_type) { | 1137 case REG_RDI: switch (operand_type) { |
| 1145 case OPERAND_SIZE_8_BIT: if (rex_prefix) | 1138 case OPERAND_TYPE_8_BIT: if (rex_prefix) |
| 1146 printf("%%dil"); | 1139 printf("%%dil"); |
| 1147 else | 1140 else |
| 1148 printf("%%bh"); | 1141 printf("%%bh"); |
| 1149 break; | 1142 break; |
| 1150 case OPERAND_SIZE_16_BIT: printf("%%di"); break; | 1143 case OPERAND_TYPE_16_BIT: printf("%%di"); break; |
| 1151 case OPERAND_SIZE_32_BIT: printf("%%edi"); break; | 1144 case OPERAND_TYPE_32_BIT: printf("%%edi"); break; |
| 1152 case OPERAND_SIZE_64_BIT: printf("%%rdi"); break; | 1145 case OPERAND_TYPE_64_BIT: printf("%%rdi"); break; |
| 1153 case OPERAND_ST: printf("%%st(7)"); break; | 1146 case OPERAND_TYPE_ST: printf("%%st(7)"); break; |
| 1154 case OPERAND_MMX: printf("%%mm7"); break; | 1147 case OPERAND_TYPE_MMX: printf("%%mm7"); break; |
| 1155 case OPERAND_FLOAT_SIZE_32_BIT: | 1148 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1156 case OPERAND_FLOAT_SIZE_64_BIT: | 1149 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1157 case OPERAND_SIZE_128_BIT: | 1150 case OPERAND_TYPE_128_BIT: |
| 1158 case OPERAND_XMM: printf("%%xmm7"); break; | 1151 case OPERAND_TYPE_XMM: printf("%%xmm7"); break; |
| 1159 case OPERAND_SIZE_256_BIT: | 1152 case OPERAND_TYPE_256_BIT: |
| 1160 case OPERAND_YMM: printf("%%ymm7"); break; | 1153 case OPERAND_TYPE_YMM: printf("%%ymm7"); break; |
| 1161 case OPERAND_CONTROL_REGISTER: printf("%%cr7"); break; | 1154 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr7"); break; |
| 1162 case OPERAND_DEBUG_REGISTER: printf("%%db7"); break; | 1155 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db7"); break; |
| 1163 default: assert(FALSE); | 1156 default: assert(FALSE); |
| 1164 } | 1157 } |
| 1165 break; | 1158 break; |
| 1166 case REG_R8: switch (operand_type) { | 1159 case REG_R8: switch (operand_type) { |
| 1167 case OPERAND_SIZE_8_BIT: printf("%%r8b"); break; | 1160 case OPERAND_TYPE_8_BIT: printf("%%r8b"); break; |
| 1168 case OPERAND_SIZE_16_BIT: printf("%%r8w"); break; | 1161 case OPERAND_TYPE_16_BIT: printf("%%r8w"); break; |
| 1169 case OPERAND_SIZE_32_BIT: printf("%%r8d"); break; | 1162 case OPERAND_TYPE_32_BIT: printf("%%r8d"); break; |
| 1170 case OPERAND_SIZE_64_BIT: printf("%%r8"); break; | 1163 case OPERAND_TYPE_64_BIT: printf("%%r8"); break; |
| 1171 case OPERAND_MMX: printf("%%mm0"); break; | 1164 case OPERAND_TYPE_MMX: printf("%%mm0"); break; |
| 1172 case OPERAND_FLOAT_SIZE_32_BIT: | 1165 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1173 case OPERAND_FLOAT_SIZE_64_BIT: | 1166 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1174 case OPERAND_SIZE_128_BIT: | 1167 case OPERAND_TYPE_128_BIT: |
| 1175 case OPERAND_XMM: printf("%%xmm8"); break; | 1168 case OPERAND_TYPE_XMM: printf("%%xmm8"); break; |
| 1176 case OPERAND_SIZE_256_BIT: | 1169 case OPERAND_TYPE_256_BIT: |
| 1177 case OPERAND_YMM: printf("%%ymm8"); break; | 1170 case OPERAND_TYPE_YMM: printf("%%ymm8"); break; |
| 1178 case OPERAND_CONTROL_REGISTER: printf("%%cr8"); break; | 1171 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr8"); break; |
| 1179 case OPERAND_DEBUG_REGISTER: printf("%%db8"); break; | 1172 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db8"); break; |
| 1180 default: assert(FALSE); | 1173 default: assert(FALSE); |
| 1181 } | 1174 } |
| 1182 break; | 1175 break; |
| 1183 case REG_R9: switch (operand_type) { | 1176 case REG_R9: switch (operand_type) { |
| 1184 case OPERAND_SIZE_8_BIT: printf("%%r9b"); break; | 1177 case OPERAND_TYPE_8_BIT: printf("%%r9b"); break; |
| 1185 case OPERAND_SIZE_16_BIT: printf("%%r9w"); break; | 1178 case OPERAND_TYPE_16_BIT: printf("%%r9w"); break; |
| 1186 case OPERAND_SIZE_32_BIT: printf("%%r9d"); break; | 1179 case OPERAND_TYPE_32_BIT: printf("%%r9d"); break; |
| 1187 case OPERAND_SIZE_64_BIT: printf("%%r9"); break; | 1180 case OPERAND_TYPE_64_BIT: printf("%%r9"); break; |
| 1188 case OPERAND_MMX: printf("%%mm1"); break; | 1181 case OPERAND_TYPE_MMX: printf("%%mm1"); break; |
| 1189 case OPERAND_FLOAT_SIZE_32_BIT: | 1182 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1190 case OPERAND_FLOAT_SIZE_64_BIT: | 1183 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1191 case OPERAND_SIZE_128_BIT: | 1184 case OPERAND_TYPE_128_BIT: |
| 1192 case OPERAND_XMM: printf("%%xmm9"); break; | 1185 case OPERAND_TYPE_XMM: printf("%%xmm9"); break; |
| 1193 case OPERAND_SIZE_256_BIT: | 1186 case OPERAND_TYPE_256_BIT: |
| 1194 case OPERAND_YMM: printf("%%ymm9"); break; | 1187 case OPERAND_TYPE_YMM: printf("%%ymm9"); break; |
| 1195 case OPERAND_CONTROL_REGISTER: printf("%%cr9"); break; | 1188 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr9"); break; |
| 1196 case OPERAND_DEBUG_REGISTER: printf("%%db9"); break; | 1189 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db9"); break; |
| 1197 default: assert(FALSE); | 1190 default: assert(FALSE); |
| 1198 } | 1191 } |
| 1199 break; | 1192 break; |
| 1200 case REG_R10: switch (operand_type) { | 1193 case REG_R10: switch (operand_type) { |
| 1201 case OPERAND_SIZE_8_BIT: printf("%%r10b"); break; | 1194 case OPERAND_TYPE_8_BIT: printf("%%r10b"); break; |
| 1202 case OPERAND_SIZE_16_BIT: printf("%%r10w"); break; | 1195 case OPERAND_TYPE_16_BIT: printf("%%r10w"); break; |
| 1203 case OPERAND_SIZE_32_BIT: printf("%%r10d"); break; | 1196 case OPERAND_TYPE_32_BIT: printf("%%r10d"); break; |
| 1204 case OPERAND_SIZE_64_BIT: printf("%%r10"); break; | 1197 case OPERAND_TYPE_64_BIT: printf("%%r10"); break; |
| 1205 case OPERAND_MMX: printf("%%mm2"); break; | 1198 case OPERAND_TYPE_MMX: printf("%%mm2"); break; |
| 1206 case OPERAND_FLOAT_SIZE_32_BIT: | 1199 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1207 case OPERAND_FLOAT_SIZE_64_BIT: | 1200 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1208 case OPERAND_SIZE_128_BIT: | 1201 case OPERAND_TYPE_128_BIT: |
| 1209 case OPERAND_XMM: printf("%%xmm10"); break; | 1202 case OPERAND_TYPE_XMM: printf("%%xmm10"); break; |
| 1210 case OPERAND_SIZE_256_BIT: | 1203 case OPERAND_TYPE_256_BIT: |
| 1211 case OPERAND_YMM: printf("%%ymm10"); break; | 1204 case OPERAND_TYPE_YMM: printf("%%ymm10"); break; |
| 1212 case OPERAND_CONTROL_REGISTER: printf("%%cr10"); break; | 1205 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr10"); break; |
| 1213 case OPERAND_DEBUG_REGISTER: printf("%%db10"); break; | 1206 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db10"); break; |
| 1214 default: assert(FALSE); | 1207 default: assert(FALSE); |
| 1215 } | 1208 } |
| 1216 break; | 1209 break; |
| 1217 case REG_R11: switch (operand_type) { | 1210 case REG_R11: switch (operand_type) { |
| 1218 case OPERAND_SIZE_8_BIT: printf("%%r11b"); break; | 1211 case OPERAND_TYPE_8_BIT: printf("%%r11b"); break; |
| 1219 case OPERAND_SIZE_16_BIT: printf("%%r11w"); break; | 1212 case OPERAND_TYPE_16_BIT: printf("%%r11w"); break; |
| 1220 case OPERAND_SIZE_32_BIT: printf("%%r11d"); break; | 1213 case OPERAND_TYPE_32_BIT: printf("%%r11d"); break; |
| 1221 case OPERAND_SIZE_64_BIT: printf("%%r11"); break; | 1214 case OPERAND_TYPE_64_BIT: printf("%%r11"); break; |
| 1222 case OPERAND_MMX: printf("%%mm3"); break; | 1215 case OPERAND_TYPE_MMX: printf("%%mm3"); break; |
| 1223 case OPERAND_FLOAT_SIZE_32_BIT: | 1216 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1224 case OPERAND_FLOAT_SIZE_64_BIT: | 1217 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1225 case OPERAND_SIZE_128_BIT: | 1218 case OPERAND_TYPE_128_BIT: |
| 1226 case OPERAND_XMM: printf("%%xmm11"); break; | 1219 case OPERAND_TYPE_XMM: printf("%%xmm11"); break; |
| 1227 case OPERAND_SIZE_256_BIT: | 1220 case OPERAND_TYPE_256_BIT: |
| 1228 case OPERAND_YMM: printf("%%ymm11"); break; | 1221 case OPERAND_TYPE_YMM: printf("%%ymm11"); break; |
| 1229 case OPERAND_CONTROL_REGISTER: printf("%%cr11"); break; | 1222 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr11"); break; |
| 1230 case OPERAND_DEBUG_REGISTER: printf("%%db11"); break; | 1223 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db11"); break; |
| 1231 default: assert(FALSE); | 1224 default: assert(FALSE); |
| 1232 } | 1225 } |
| 1233 break; | 1226 break; |
| 1234 case REG_R12: switch (operand_type) { | 1227 case REG_R12: switch (operand_type) { |
| 1235 case OPERAND_SIZE_8_BIT: printf("%%r12b"); break; | 1228 case OPERAND_TYPE_8_BIT: printf("%%r12b"); break; |
| 1236 case OPERAND_SIZE_16_BIT: printf("%%r12w"); break; | 1229 case OPERAND_TYPE_16_BIT: printf("%%r12w"); break; |
| 1237 case OPERAND_SIZE_32_BIT: printf("%%r12d"); break; | 1230 case OPERAND_TYPE_32_BIT: printf("%%r12d"); break; |
| 1238 case OPERAND_SIZE_64_BIT: printf("%%r12"); break; | 1231 case OPERAND_TYPE_64_BIT: printf("%%r12"); break; |
| 1239 case OPERAND_MMX: printf("%%mm4"); break; | 1232 case OPERAND_TYPE_MMX: printf("%%mm4"); break; |
| 1240 case OPERAND_FLOAT_SIZE_32_BIT: | 1233 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1241 case OPERAND_FLOAT_SIZE_64_BIT: | 1234 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1242 case OPERAND_SIZE_128_BIT: | 1235 case OPERAND_TYPE_128_BIT: |
| 1243 case OPERAND_XMM: printf("%%xmm12"); break; | 1236 case OPERAND_TYPE_XMM: printf("%%xmm12"); break; |
| 1244 case OPERAND_SIZE_256_BIT: | 1237 case OPERAND_TYPE_256_BIT: |
| 1245 case OPERAND_YMM: printf("%%ymm12"); break; | 1238 case OPERAND_TYPE_YMM: printf("%%ymm12"); break; |
| 1246 case OPERAND_CONTROL_REGISTER: printf("%%cr12"); break; | 1239 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr12"); break; |
| 1247 case OPERAND_DEBUG_REGISTER: printf("%%db12"); break; | 1240 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db12"); break; |
| 1248 default: assert(FALSE); | 1241 default: assert(FALSE); |
| 1249 } | 1242 } |
| 1250 break; | 1243 break; |
| 1251 case REG_R13: switch (operand_type) { | 1244 case REG_R13: switch (operand_type) { |
| 1252 case OPERAND_SIZE_8_BIT: printf("%%r13b"); break; | 1245 case OPERAND_TYPE_8_BIT: printf("%%r13b"); break; |
| 1253 case OPERAND_SIZE_16_BIT: printf("%%r13w"); break; | 1246 case OPERAND_TYPE_16_BIT: printf("%%r13w"); break; |
| 1254 case OPERAND_SIZE_32_BIT: printf("%%r13d"); break; | 1247 case OPERAND_TYPE_32_BIT: printf("%%r13d"); break; |
| 1255 case OPERAND_SIZE_64_BIT: printf("%%r13"); break; | 1248 case OPERAND_TYPE_64_BIT: printf("%%r13"); break; |
| 1256 case OPERAND_MMX: printf("%%mm5"); break; | 1249 case OPERAND_TYPE_MMX: printf("%%mm5"); break; |
| 1257 case OPERAND_FLOAT_SIZE_32_BIT: | 1250 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1258 case OPERAND_FLOAT_SIZE_64_BIT: | 1251 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1259 case OPERAND_SIZE_128_BIT: | 1252 case OPERAND_TYPE_128_BIT: |
| 1260 case OPERAND_XMM: printf("%%xmm13"); break; | 1253 case OPERAND_TYPE_XMM: printf("%%xmm13"); break; |
| 1261 case OPERAND_SIZE_256_BIT: | 1254 case OPERAND_TYPE_256_BIT: |
| 1262 case OPERAND_YMM: printf("%%ymm13"); break; | 1255 case OPERAND_TYPE_YMM: printf("%%ymm13"); break; |
| 1263 case OPERAND_CONTROL_REGISTER: printf("%%cr13"); break; | 1256 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr13"); break; |
| 1264 case OPERAND_DEBUG_REGISTER: printf("%%db13"); break; | 1257 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db13"); break; |
| 1265 default: assert(FALSE); | 1258 default: assert(FALSE); |
| 1266 } | 1259 } |
| 1267 break; | 1260 break; |
| 1268 case REG_R14: switch (operand_type) { | 1261 case REG_R14: switch (operand_type) { |
| 1269 case OPERAND_SIZE_8_BIT: printf("%%r14b"); break; | 1262 case OPERAND_TYPE_8_BIT: printf("%%r14b"); break; |
| 1270 case OPERAND_SIZE_16_BIT: printf("%%r14w"); break; | 1263 case OPERAND_TYPE_16_BIT: printf("%%r14w"); break; |
| 1271 case OPERAND_SIZE_32_BIT: printf("%%r14d"); break; | 1264 case OPERAND_TYPE_32_BIT: printf("%%r14d"); break; |
| 1272 case OPERAND_SIZE_64_BIT: printf("%%r14"); break; | 1265 case OPERAND_TYPE_64_BIT: printf("%%r14"); break; |
| 1273 case OPERAND_MMX: printf("%%mm6"); break; | 1266 case OPERAND_TYPE_MMX: printf("%%mm6"); break; |
| 1274 case OPERAND_FLOAT_SIZE_32_BIT: | 1267 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1275 case OPERAND_FLOAT_SIZE_64_BIT: | 1268 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1276 case OPERAND_SIZE_128_BIT: | 1269 case OPERAND_TYPE_128_BIT: |
| 1277 case OPERAND_XMM: printf("%%xmm14"); break; | 1270 case OPERAND_TYPE_XMM: printf("%%xmm14"); break; |
| 1278 case OPERAND_SIZE_256_BIT: | 1271 case OPERAND_TYPE_256_BIT: |
| 1279 case OPERAND_YMM: printf("%%ymm14"); break; | 1272 case OPERAND_TYPE_YMM: printf("%%ymm14"); break; |
| 1280 case OPERAND_CONTROL_REGISTER: printf("%%cr14"); break; | 1273 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr14"); break; |
| 1281 case OPERAND_DEBUG_REGISTER: printf("%%db14"); break; | 1274 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db14"); break; |
| 1282 default: assert(FALSE); | 1275 default: assert(FALSE); |
| 1283 } | 1276 } |
| 1284 break; | 1277 break; |
| 1285 case REG_R15: switch (operand_type) { | 1278 case REG_R15: switch (operand_type) { |
| 1286 case OPERAND_SIZE_8_BIT: printf("%%r15b"); break; | 1279 case OPERAND_TYPE_8_BIT: printf("%%r15b"); break; |
| 1287 case OPERAND_SIZE_16_BIT: printf("%%r15w"); break; | 1280 case OPERAND_TYPE_16_BIT: printf("%%r15w"); break; |
| 1288 case OPERAND_SIZE_32_BIT: printf("%%r15d"); break; | 1281 case OPERAND_TYPE_32_BIT: printf("%%r15d"); break; |
| 1289 case OPERAND_SIZE_64_BIT: printf("%%r15"); break; | 1282 case OPERAND_TYPE_64_BIT: printf("%%r15"); break; |
| 1290 case OPERAND_MMX: printf("%%mm7"); break; | 1283 case OPERAND_TYPE_MMX: printf("%%mm7"); break; |
| 1291 case OPERAND_FLOAT_SIZE_32_BIT: | 1284 case OPERAND_TYPE_FLOAT_32_BIT: |
| 1292 case OPERAND_FLOAT_SIZE_64_BIT: | 1285 case OPERAND_TYPE_FLOAT_64_BIT: |
| 1293 case OPERAND_SIZE_128_BIT: | 1286 case OPERAND_TYPE_128_BIT: |
| 1294 case OPERAND_XMM: printf("%%xmm15"); break; | 1287 case OPERAND_TYPE_XMM: printf("%%xmm15"); break; |
| 1295 case OPERAND_SIZE_256_BIT: | 1288 case OPERAND_TYPE_256_BIT: |
| 1296 case OPERAND_YMM: printf("%%ymm15"); break; | 1289 case OPERAND_TYPE_YMM: printf("%%ymm15"); break; |
| 1297 case OPERAND_CONTROL_REGISTER: printf("%%cr15"); break; | 1290 case OPERAND_TYPE_CONTROL_REGISTER: printf("%%cr15"); break; |
| 1298 case OPERAND_DEBUG_REGISTER: printf("%%db15"); break; | 1291 case OPERAND_TYPE_DEBUG_REGISTER: printf("%%db15"); break; |
| 1299 default: assert(FALSE); | 1292 default: assert(FALSE); |
| 1300 } | 1293 } |
| 1301 break; | 1294 break; |
| 1302 case REG_ST: | 1295 case REG_ST: |
| 1303 assert(operand_type == OPERAND_ST); | 1296 assert(operand_type == OPERAND_TYPE_ST); |
| 1304 printf("%%st"); | 1297 printf("%%st"); |
| 1305 break; | 1298 break; |
| 1306 case REG_RM: { | 1299 case REG_RM: { |
| 1307 if (instruction->rm.disp_type != DISPNONE) { | 1300 if (instruction->rm.disp_type != DISPNONE) { |
| 1308 if ((instruction->rm.disp_type == DISP64) || | 1301 if ((instruction->rm.disp_type == DISP64) || |
| 1309 (instruction->rm.offset >= 0)) | 1302 (instruction->rm.offset >= 0)) |
| 1310 printf("0x%"NACL_PRIx64, instruction->rm.offset); | 1303 printf("0x%"NACL_PRIx64, instruction->rm.offset); |
| 1311 else | 1304 else |
| 1312 printf("-0x%"NACL_PRIx64, -instruction->rm.offset); | 1305 printf("-0x%"NACL_PRIx64, -instruction->rm.offset); |
| 1313 } | 1306 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1488 } else { | 1481 } else { |
| 1489 printf("%%es:(%%rdi)"); | 1482 printf("%%es:(%%rdi)"); |
| 1490 } | 1483 } |
| 1491 break; | 1484 break; |
| 1492 case REG_DS_RSI: if (((struct DecodeState *)userdata)->ia32_mode) { | 1485 case REG_DS_RSI: if (((struct DecodeState *)userdata)->ia32_mode) { |
| 1493 printf("%%ds:(%%esi)"); | 1486 printf("%%ds:(%%esi)"); |
| 1494 } else { | 1487 } else { |
| 1495 printf("%%ds:(%%rsi)"); | 1488 printf("%%ds:(%%rsi)"); |
| 1496 } | 1489 } |
| 1497 break; | 1490 break; |
| 1498 case JMP_TO: if (instruction->operands[0].type == OPERAND_SIZE_16_BIT) | 1491 case JMP_TO: if (instruction->operands[0].type == OPERAND_TYPE_16_BIT) |
| 1499 printf("0x%lx", (long)((end + instruction->rm.offset - | 1492 printf("0x%lx", (long)((end + instruction->rm.offset - |
| 1500 (((struct DecodeState *)userdata)->offset)) & 0xffff)); | 1493 (((struct DecodeState *)userdata)->offset)) & 0xffff)); |
| 1501 else | 1494 else |
| 1502 printf("0x%lx", (long)(end + instruction->rm.offset - | 1495 printf("0x%lx", (long)(end + instruction->rm.offset - |
| 1503 (((struct DecodeState *)userdata)->offset))); | 1496 (((struct DecodeState *)userdata)->offset))); |
| 1504 break; | 1497 break; |
| 1505 case REG_RIP: | 1498 case REG_RIP: |
| 1506 case REG_RIZ: | 1499 case REG_RIZ: |
| 1507 case NO_REG: | 1500 case NO_REG: |
| 1508 assert(FALSE); | 1501 assert(FALSE); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1657 for (index = initial_index; index < argc; ++index) { | 1650 for (index = initial_index; index < argc; ++index) { |
| 1658 const char *filename = argv[index]; | 1651 const char *filename = argv[index]; |
| 1659 int rc = DecodeFile(filename, repeat_count); | 1652 int rc = DecodeFile(filename, repeat_count); |
| 1660 if (!rc) { | 1653 if (!rc) { |
| 1661 printf("file '%s' can not be fully decoded\n", filename); | 1654 printf("file '%s' can not be fully decoded\n", filename); |
| 1662 return 1; | 1655 return 1; |
| 1663 } | 1656 } |
| 1664 } | 1657 } |
| 1665 return 0; | 1658 return 0; |
| 1666 } | 1659 } |
| OLD | NEW |