Lines Matching +full:0 +full:d
88 data_prefix (struct output_data *d) in data_prefix() argument
90 char ch = '\0'; in data_prefix()
91 if (*d->prefixes & has_cs) in data_prefix()
94 *d->prefixes &= ~has_cs; in data_prefix()
96 else if (*d->prefixes & has_ds) in data_prefix()
98 ch = 'd'; in data_prefix()
99 *d->prefixes &= ~has_ds; in data_prefix()
101 else if (*d->prefixes & has_es) in data_prefix()
104 *d->prefixes &= ~has_es; in data_prefix()
106 else if (*d->prefixes & has_fs) in data_prefix()
109 *d->prefixes &= ~has_fs; in data_prefix()
111 else if (*d->prefixes & has_gs) in data_prefix()
114 *d->prefixes &= ~has_gs; in data_prefix()
116 else if (*d->prefixes & has_ss) in data_prefix()
119 *d->prefixes &= ~has_ss; in data_prefix()
122 return 0; in data_prefix()
124 if (*d->bufcntp + 4 > d->bufsize) in data_prefix()
125 return *d->bufcntp + 4 - d->bufsize; in data_prefix()
127 d->bufp[(*d->bufcntp)++] = '%'; in data_prefix()
128 d->bufp[(*d->bufcntp)++] = ch; in data_prefix()
129 d->bufp[(*d->bufcntp)++] = 's'; in data_prefix()
130 d->bufp[(*d->bufcntp)++] = ':'; in data_prefix()
132 return 0; in data_prefix()
157 general_mod$r_m (struct output_data *d) in general_mod$r_m() argument
159 int r = data_prefix (d); in general_mod$r_m()
160 if (r != 0) in general_mod$r_m()
163 int prefixes = *d->prefixes; in general_mod$r_m()
164 const uint8_t *data = &d->data[d->opoff1 / 8]; in general_mod$r_m()
165 char *bufp = d->bufp; in general_mod$r_m()
166 size_t *bufcntp = d->bufcntp; in general_mod$r_m()
167 size_t bufsize = d->bufsize; in general_mod$r_m()
169 uint_fast8_t modrm = data[0]; in general_mod$r_m()
171 if (unlikely ((prefixes & has_addr16) != 0)) in general_mod$r_m()
173 int16_t disp = 0; in general_mod$r_m()
176 if ((modrm & 0xc7) == 6 || (modrm & 0xc0) == 0x80) in general_mod$r_m()
179 else if ((modrm & 0xc0) == 0x40) in general_mod$r_m()
182 else if ((modrm & 0xc0) == 0) in general_mod$r_m()
185 char tmpbuf[sizeof ("-0x1234(%rr,%rr)")]; in general_mod$r_m()
187 if ((modrm & 0xc7) == 6) in general_mod$r_m()
188 n = snprintf (tmpbuf, sizeof (tmpbuf), "0x%" PRIx16, disp); in general_mod$r_m()
191 n = 0; in general_mod$r_m()
194 disp < 0 ? "-" : "", disp < 0 ? -disp : disp); in general_mod$r_m()
196 if ((modrm & 0x4) == 0) in general_mod$r_m()
215 int32_t disp = 0; in general_mod$r_m()
218 if ((modrm & 0xc7) == 5 || (modrm & 0xc0) == 0x80) in general_mod$r_m()
221 else if ((modrm & 0xc0) == 0x40) in general_mod$r_m()
224 else if ((modrm & 0xc0) == 0) in general_mod$r_m()
227 char tmpbuf[sizeof ("-0x12345678(%rrrr)")]; in general_mod$r_m()
240 tmpbuf[n++] = 'd'; in general_mod$r_m()
246 else if ((modrm & 0xc7) != 5) in general_mod$r_m()
250 disp < 0 ? "-" : "", disp < 0 ? -disp : disp, &p, in general_mod$r_m()
259 tmpbuf[n++] = 'd'; in general_mod$r_m()
269 disp < 0 ? "-" : "", disp < 0 ? -disp : disp); in general_mod$r_m()
271 d->symaddr_use = addr_rel_always; in general_mod$r_m()
272 d->symaddr = disp; in general_mod$r_m()
274 n = snprintf (tmpbuf, sizeof (tmpbuf), "0x%" PRIx32, disp); in general_mod$r_m()
288 int32_t disp = 0; in general_mod$r_m()
291 if ((modrm & 0xc7) == 5 || (modrm & 0xc0) == 0x80 in general_mod$r_m()
292 || ((modrm & 0xc7) == 0x4 && (sib & 0x7) == 0x5)) in general_mod$r_m()
295 else if ((modrm & 0xc0) == 0x40) in general_mod$r_m()
301 char tmpbuf[sizeof ("-0x12345678(%rrrr,%rrrr,N)")]; in general_mod$r_m()
304 if ((modrm & 0xc0) != 0 || (sib & 0x3f) != 0x25 in general_mod$r_m()
306 || (prefixes & has_rex_x) != 0 in general_mod$r_m()
313 disp < 0 ? "-" : "", disp < 0 ? -disp : disp); in general_mod$r_m()
319 if ((modrm & 0xc7) != 0x4 || (sib & 0x7) != 0x5) in general_mod$r_m()
331 *cp++ = 'd'; in general_mod$r_m()
335 if ((sib & 0x38) != 0x20 in general_mod$r_m()
337 || (prefixes & has_rex_x) != 0 in general_mod$r_m()
354 *cp++ = 'd'; in general_mod$r_m()
358 *cp++ = '0' + (1 << (sib >> 6)); in general_mod$r_m()
367 if ((prefixes & has_addr16) == 0) in general_mod$r_m()
368 n = snprintf (cp, sizeof (tmpbuf), "0x%" PRIx64, in general_mod$r_m()
372 n = snprintf (cp, sizeof (tmpbuf), "0x%" PRIx32, disp); in general_mod$r_m()
383 return 0; in general_mod$r_m()
388 FCT_MOD$R_M (struct output_data *d) in FCT_MOD$R_M() argument
390 assert (d->opoff1 % 8 == 0); in FCT_MOD$R_M()
391 uint_fast8_t modrm = d->data[d->opoff1 / 8]; in FCT_MOD$R_M()
392 if ((modrm & 0xc0) == 0xc0) in FCT_MOD$R_M()
394 assert (d->opoff1 / 8 == d->opoff2 / 8); in FCT_MOD$R_M()
395 assert (d->opoff2 % 8 == 5); in FCT_MOD$R_M()
396 //uint_fast8_t byte = d->data[d->opoff2 / 8] & 7; in FCT_MOD$R_M()
399 size_t *bufcntp = d->bufcntp; in FCT_MOD$R_M()
400 char *buf = d->bufp + *bufcntp; in FCT_MOD$R_M()
401 size_t avail = d->bufsize - *bufcntp; in FCT_MOD$R_M()
403 if (*d->prefixes & (has_rep | has_repne)) in FCT_MOD$R_M()
410 return 0; in FCT_MOD$R_M()
413 return general_mod$r_m (d); in FCT_MOD$R_M()
418 FCT_Mod$R_m (struct output_data *d) in FCT_Mod$R_m() argument
420 assert (d->opoff1 % 8 == 0); in FCT_Mod$R_m()
421 uint_fast8_t modrm = d->data[d->opoff1 / 8]; in FCT_Mod$R_m()
422 if ((modrm & 0xc0) == 0xc0) in FCT_Mod$R_m()
424 assert (d->opoff1 / 8 == d->opoff2 / 8); in FCT_Mod$R_m()
425 assert (d->opoff2 % 8 == 5); in FCT_Mod$R_m()
429 size_t *bufcntp = d->bufcntp; in FCT_Mod$R_m()
430 size_t avail = d->bufsize - *bufcntp; in FCT_Mod$R_m()
431 int needed = snprintf (&d->bufp[*bufcntp], avail, "%%xmm%" PRIxFAST8, in FCT_Mod$R_m()
435 *d->bufcntp += needed; in FCT_Mod$R_m()
436 return 0; in FCT_Mod$R_m()
439 return general_mod$r_m (d); in FCT_Mod$R_m()
443 generic_abs (struct output_data *d, const char *absstring in generic_abs() argument
451 int r = data_prefix (d); in generic_abs()
452 if (r != 0) in generic_abs()
455 assert (d->opoff1 % 8 == 0); in generic_abs()
456 assert (d->opoff1 / 8 == 1); in generic_abs()
457 if (*d->param_start + abslen > d->end) in generic_abs()
459 *d->param_start += abslen; in generic_abs()
467 absval = read_8ubyte_unaligned (&d->data[1]); in generic_abs()
470 absval = read_4ubyte_unaligned (&d->data[1]); in generic_abs()
471 size_t *bufcntp = d->bufcntp; in generic_abs()
472 size_t avail = d->bufsize - *bufcntp; in generic_abs()
473 int needed = snprintf (&d->bufp[*bufcntp], avail, "%s0x%" ABSPRIFMT, in generic_abs()
478 return 0; in generic_abs()
483 FCT_absval (struct output_data *d) in FCT_absval() argument
485 return generic_abs (d, "$" in FCT_absval()
493 FCT_abs (struct output_data *d) in FCT_abs() argument
495 return generic_abs (d, "" in FCT_abs()
503 FCT_ax (struct output_data *d) in FCT_ax() argument
505 int is_16bit = (*d->prefixes & has_data16) != 0; in FCT_ax()
507 size_t *bufcntp = d->bufcntp; in FCT_ax()
508 char *bufp = d->bufp; in FCT_ax()
509 size_t bufsize = d->bufsize; in FCT_ax()
518 (*d->prefixes & has_rex_w) ? 'r' : in FCT_ax()
524 return 0; in FCT_ax()
529 FCT_ax$w (struct output_data *d) in FCT_ax$w() argument
531 if ((d->data[d->opoff2 / 8] & (1 << (7 - (d->opoff2 & 7)))) != 0) in FCT_ax$w()
532 return FCT_ax (d); in FCT_ax$w()
534 size_t *bufcntp = d->bufcntp; in FCT_ax$w()
535 char *bufp = d->bufp; in FCT_ax$w()
536 size_t bufsize = d->bufsize; in FCT_ax$w()
545 return 0; in FCT_ax$w()
551 FCT_crdb (struct output_data *d, const char *regstr) in FCT_crdb() argument
553 if (*d->prefixes & has_data16) in FCT_crdb()
556 size_t *bufcntp = d->bufcntp; in FCT_crdb()
559 assert (d->opoff1 / 8 == 2); in FCT_crdb()
560 assert (d->opoff1 % 8 == 2); in FCT_crdb()
561 size_t avail = d->bufsize - *bufcntp; in FCT_crdb()
562 int needed = snprintf (&d->bufp[*bufcntp], avail, "%%%s%" PRIx32, in FCT_crdb()
563 regstr, (uint32_t) (d->data[d->opoff1 / 8] >> 3) & 7); in FCT_crdb()
567 return 0; in FCT_crdb()
572 FCT_ccc (struct output_data *d) in FCT_ccc() argument
574 return FCT_crdb (d, "cr"); in FCT_ccc()
579 FCT_ddd (struct output_data *d) in FCT_ddd() argument
581 return FCT_crdb (d, "db"); in FCT_ddd()
586 FCT_disp8 (struct output_data *d) in FCT_disp8() argument
588 assert (d->opoff1 % 8 == 0); in FCT_disp8()
589 if (*d->param_start >= d->end) in FCT_disp8()
591 int32_t offset = *(const int8_t *) (*d->param_start)++; in FCT_disp8()
593 size_t *bufcntp = d->bufcntp; in FCT_disp8()
594 size_t avail = d->bufsize - *bufcntp; in FCT_disp8()
595 int needed = snprintf (&d->bufp[*bufcntp], avail, "0x%" PRIx32, in FCT_disp8()
596 (uint32_t) (d->addr + (*d->param_start - d->data) in FCT_disp8()
601 return 0; in FCT_disp8()
607 FCT_ds_xx (struct output_data *d, const char *reg) in FCT_ds_xx() argument
609 int prefix = *d->prefixes & SEGMENT_PREFIXES; in FCT_ds_xx()
611 if (prefix == 0) in FCT_ds_xx()
612 *d->prefixes |= prefix = has_ds; in FCT_ds_xx()
617 int r = data_prefix (d); in FCT_ds_xx()
619 assert ((*d->prefixes & prefix) == 0); in FCT_ds_xx()
621 if (r != 0) in FCT_ds_xx()
624 size_t *bufcntp = d->bufcntp; in FCT_ds_xx()
625 size_t avail = d->bufsize - *bufcntp; in FCT_ds_xx()
626 int needed = snprintf (&d->bufp[*bufcntp], avail, "(%%%s%s)", in FCT_ds_xx()
628 *d->prefixes & idx_addr16 ? "e" : "r", in FCT_ds_xx()
630 *d->prefixes & idx_addr16 ? "" : "e", in FCT_ds_xx()
637 return 0; in FCT_ds_xx()
642 FCT_ds_bx (struct output_data *d) in FCT_ds_bx() argument
644 return FCT_ds_xx (d, "bx"); in FCT_ds_bx()
649 FCT_ds_si (struct output_data *d) in FCT_ds_si() argument
651 return FCT_ds_xx (d, "si"); in FCT_ds_si()
656 FCT_dx (struct output_data *d) in FCT_dx() argument
658 size_t *bufcntp = d->bufcntp; in FCT_dx()
660 if (*bufcntp + 7 > d->bufsize) in FCT_dx()
661 return *bufcntp + 7 - d->bufsize; in FCT_dx()
663 memcpy (&d->bufp[*bufcntp], "(%dx)", 5); in FCT_dx()
666 return 0; in FCT_dx()
671 FCT_es_di (struct output_data *d) in FCT_es_di() argument
673 size_t *bufcntp = d->bufcntp; in FCT_es_di()
674 size_t avail = d->bufsize - *bufcntp; in FCT_es_di()
675 int needed = snprintf (&d->bufp[*bufcntp], avail, "%%es:(%%%sdi)", in FCT_es_di()
677 *d->prefixes & idx_addr16 ? "e" : "r" in FCT_es_di()
679 *d->prefixes & idx_addr16 ? "" : "e" in FCT_es_di()
686 return 0; in FCT_es_di()
691 FCT_imm (struct output_data *d) in FCT_imm() argument
693 size_t *bufcntp = d->bufcntp; in FCT_imm()
694 size_t avail = d->bufsize - *bufcntp; in FCT_imm()
696 if (*d->prefixes & has_data16) in FCT_imm()
698 if (*d->param_start + 2 > d->end) in FCT_imm()
700 uint16_t word = read_2ubyte_unaligned_inc (*d->param_start); in FCT_imm()
701 needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx16, word); in FCT_imm()
705 if (*d->param_start + 4 > d->end) in FCT_imm()
707 int32_t word = read_4sbyte_unaligned_inc (*d->param_start); in FCT_imm()
709 if (*d->prefixes & has_rex_w) in FCT_imm()
710 needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx64, in FCT_imm()
714 needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, word); in FCT_imm()
719 return 0; in FCT_imm()
724 FCT_imm$w (struct output_data *d) in FCT_imm$w() argument
726 if ((d->data[d->opoff2 / 8] & (1 << (7 - (d->opoff2 & 7)))) != 0) in FCT_imm$w()
727 return FCT_imm (d); in FCT_imm$w()
729 size_t *bufcntp = d->bufcntp; in FCT_imm$w()
730 size_t avail = d->bufsize - *bufcntp; in FCT_imm$w()
731 if (*d->param_start>= d->end) in FCT_imm$w()
733 uint_fast8_t word = *(*d->param_start)++; in FCT_imm$w()
734 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIxFAST8, word); in FCT_imm$w()
738 return 0; in FCT_imm$w()
744 FCT_imm64$w (struct output_data *d) in FCT_imm64$w() argument
746 if ((d->data[d->opoff2 / 8] & (1 << (7 - (d->opoff2 & 7)))) == 0 in FCT_imm64$w()
747 || (*d->prefixes & has_data16) != 0) in FCT_imm64$w()
748 return FCT_imm$w (d); in FCT_imm64$w()
750 size_t *bufcntp = d->bufcntp; in FCT_imm64$w()
751 size_t avail = d->bufsize - *bufcntp; in FCT_imm64$w()
753 if (*d->prefixes & has_rex_w) in FCT_imm64$w()
755 if (*d->param_start + 8 > d->end) in FCT_imm64$w()
757 uint64_t word = read_8ubyte_unaligned_inc (*d->param_start); in FCT_imm64$w()
758 needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx64, word); in FCT_imm64$w()
762 if (*d->param_start + 4 > d->end) in FCT_imm64$w()
764 int32_t word = read_4sbyte_unaligned_inc (*d->param_start); in FCT_imm64$w()
765 needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, word); in FCT_imm64$w()
770 return 0; in FCT_imm64$w()
776 FCT_imms (struct output_data *d) in FCT_imms() argument
778 size_t *bufcntp = d->bufcntp; in FCT_imms()
779 size_t avail = d->bufsize - *bufcntp; in FCT_imms()
780 if (*d->param_start>= d->end) in FCT_imms()
782 int8_t byte = *(*d->param_start)++; in FCT_imms()
784 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx64, in FCT_imms()
787 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, in FCT_imms()
793 return 0; in FCT_imms()
798 FCT_imm$s (struct output_data *d) in FCT_imm$s() argument
800 uint_fast8_t opcode = d->data[d->opoff2 / 8]; in FCT_imm$s()
801 size_t *bufcntp = d->bufcntp; in FCT_imm$s()
802 size_t avail = d->bufsize - *bufcntp; in FCT_imm$s()
803 if ((opcode & 2) != 0) in FCT_imm$s()
804 return FCT_imms (d); in FCT_imm$s()
806 if ((*d->prefixes & has_data16) == 0) in FCT_imm$s()
808 if (*d->param_start + 4 > d->end) in FCT_imm$s()
810 int32_t word = read_4sbyte_unaligned_inc (*d->param_start); in FCT_imm$s()
812 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx64, in FCT_imm$s()
815 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, word); in FCT_imm$s()
823 if (*d->param_start + 2 > d->end) in FCT_imm$s()
825 uint16_t word = read_2ubyte_unaligned_inc (*d->param_start); in FCT_imm$s()
826 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx16, word); in FCT_imm$s()
831 return 0; in FCT_imm$s()
836 FCT_imm16 (struct output_data *d) in FCT_imm16() argument
838 if (*d->param_start + 2 > d->end) in FCT_imm16()
840 uint16_t word = read_2ubyte_unaligned_inc (*d->param_start); in FCT_imm16()
841 size_t *bufcntp = d->bufcntp; in FCT_imm16()
842 size_t avail = d->bufsize - *bufcntp; in FCT_imm16()
843 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx16, word); in FCT_imm16()
847 return 0; in FCT_imm16()
852 FCT_imms8 (struct output_data *d) in FCT_imms8() argument
854 size_t *bufcntp = d->bufcntp; in FCT_imms8()
855 size_t avail = d->bufsize - *bufcntp; in FCT_imms8()
856 if (*d->param_start >= d->end) in FCT_imms8()
858 int_fast8_t byte = *(*d->param_start)++; in FCT_imms8()
861 if (*d->prefixes & has_rex_w) in FCT_imms8()
862 needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx64, in FCT_imms8()
866 needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, in FCT_imms8()
871 return 0; in FCT_imms8()
876 FCT_imm8 (struct output_data *d) in FCT_imm8() argument
878 size_t *bufcntp = d->bufcntp; in FCT_imm8()
879 size_t avail = d->bufsize - *bufcntp; in FCT_imm8()
880 if (*d->param_start >= d->end) in FCT_imm8()
882 uint_fast8_t byte = *(*d->param_start)++; in FCT_imm8()
883 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, in FCT_imm8()
888 return 0; in FCT_imm8()
893 FCT_rel (struct output_data *d) in FCT_rel() argument
895 size_t *bufcntp = d->bufcntp; in FCT_rel()
896 size_t avail = d->bufsize - *bufcntp; in FCT_rel()
897 if (*d->param_start + 4 > d->end) in FCT_rel()
899 int32_t rel = read_4sbyte_unaligned_inc (*d->param_start); in FCT_rel()
901 int needed = snprintf (&d->bufp[*bufcntp], avail, "0x%" PRIx64, in FCT_rel()
902 (uint64_t) (d->addr + rel in FCT_rel()
903 + (*d->param_start - d->data))); in FCT_rel()
905 int needed = snprintf (&d->bufp[*bufcntp], avail, "0x%" PRIx32, in FCT_rel()
906 (uint32_t) (d->addr + rel in FCT_rel()
907 + (*d->param_start - d->data))); in FCT_rel()
912 return 0; in FCT_rel()
917 FCT_mmxreg (struct output_data *d) in FCT_mmxreg() argument
919 uint_fast8_t byte = d->data[d->opoff1 / 8]; in FCT_mmxreg()
920 assert (d->opoff1 % 8 == 2 || d->opoff1 % 8 == 5); in FCT_mmxreg()
921 byte = (byte >> (5 - d->opoff1 % 8)) & 7; in FCT_mmxreg()
922 size_t *bufcntp = d->bufcntp; in FCT_mmxreg()
923 size_t avail = d->bufsize - *bufcntp; in FCT_mmxreg()
924 int needed = snprintf (&d->bufp[*bufcntp], avail, "%%mm%" PRIxFAST8, byte); in FCT_mmxreg()
928 return 0; in FCT_mmxreg()
933 FCT_mod$r_m (struct output_data *d) in FCT_mod$r_m() argument
935 assert (d->opoff1 % 8 == 0); in FCT_mod$r_m()
936 uint_fast8_t modrm = d->data[d->opoff1 / 8]; in FCT_mod$r_m()
937 if ((modrm & 0xc0) == 0xc0) in FCT_mod$r_m()
939 int prefixes = *d->prefixes; in FCT_mod$r_m()
943 int is_16bit = (prefixes & has_data16) != 0; in FCT_mod$r_m()
945 size_t *bufcntp = d->bufcntp; in FCT_mod$r_m()
946 char *bufp = d->bufp; in FCT_mod$r_m()
947 if (*bufcntp + 5 - is_16bit > d->bufsize) in FCT_mod$r_m()
948 return *bufcntp + 5 - is_16bit - d->bufsize; in FCT_mod$r_m()
953 if ((prefixes & has_rex_b) != 0 && !is_16bit) in FCT_mod$r_m()
956 if ((prefixes & has_rex_w) == 0) in FCT_mod$r_m()
957 *cp++ = 'd'; in FCT_mod$r_m()
964 if ((prefixes & has_rex_w) != 0) in FCT_mod$r_m()
969 return 0; in FCT_mod$r_m()
972 return general_mod$r_m (d); in FCT_mod$r_m()
978 FCT_moda$r_m (struct output_data *d) in FCT_moda$r_m() argument
980 assert (d->opoff1 % 8 == 0); in FCT_moda$r_m()
981 uint_fast8_t modrm = d->data[d->opoff1 / 8]; in FCT_moda$r_m()
982 if ((modrm & 0xc0) == 0xc0) in FCT_moda$r_m()
984 if (*d->prefixes & has_addr16) in FCT_moda$r_m()
987 size_t *bufcntp = d->bufcntp; in FCT_moda$r_m()
988 if (*bufcntp + 3 > d->bufsize) in FCT_moda$r_m()
989 return *bufcntp + 3 - d->bufsize; in FCT_moda$r_m()
991 memcpy (&d->bufp[*bufcntp], "???", 3); in FCT_moda$r_m()
994 return 0; in FCT_moda$r_m()
997 return general_mod$r_m (d); in FCT_moda$r_m()
1005 [0] = "a", [1] = "c", [2] = "d", [3] = "b",
1012 FCT_mod$r_m$w (struct output_data *d) in FCT_mod$r_m$w() argument
1014 assert (d->opoff1 % 8 == 0); in FCT_mod$r_m$w()
1015 const uint8_t *data = d->data; in FCT_mod$r_m$w()
1016 uint_fast8_t modrm = data[d->opoff1 / 8]; in FCT_mod$r_m$w()
1017 if ((modrm & 0xc0) == 0xc0) in FCT_mod$r_m$w()
1019 int prefixes = *d->prefixes; in FCT_mod$r_m$w()
1024 size_t *bufcntp = d->bufcntp; in FCT_mod$r_m$w()
1025 char *bufp = d->bufp; in FCT_mod$r_m$w()
1026 if (*bufcntp + 5 > d->bufsize) in FCT_mod$r_m$w()
1027 return *bufcntp + 5 - d->bufsize; in FCT_mod$r_m$w()
1029 if ((data[d->opoff3 / 8] & (1 << (7 - (d->opoff3 & 7)))) == 0) in FCT_mod$r_m$w()
1037 *bufcntp += snprintf (bufp + *bufcntp, d->bufsize - *bufcntp, in FCT_mod$r_m$w()
1055 int is_16bit = (prefixes & has_data16) != 0; in FCT_mod$r_m$w()
1061 if ((prefixes & has_rex_b) != 0 && !is_16bit) in FCT_mod$r_m$w()
1064 if ((prefixes & has_rex_w) == 0) in FCT_mod$r_m$w()
1065 *cp++ = 'd'; in FCT_mod$r_m$w()
1072 if ((prefixes & has_rex_w) != 0) in FCT_mod$r_m$w()
1078 return 0; in FCT_mod$r_m$w()
1081 return general_mod$r_m (d); in FCT_mod$r_m$w()
1086 FCT_mod$8r_m (struct output_data *d) in FCT_mod$8r_m() argument
1088 assert (d->opoff1 % 8 == 0); in FCT_mod$8r_m()
1089 uint_fast8_t modrm = d->data[d->opoff1 / 8]; in FCT_mod$8r_m()
1090 if ((modrm & 0xc0) == 0xc0) in FCT_mod$8r_m()
1092 size_t *bufcntp = d->bufcntp; in FCT_mod$8r_m()
1093 char *bufp = d->bufp; in FCT_mod$8r_m()
1094 if (*bufcntp + 3 > d->bufsize) in FCT_mod$8r_m()
1095 return *bufcntp + 3 - d->bufsize; in FCT_mod$8r_m()
1099 return 0; in FCT_mod$8r_m()
1102 return general_mod$r_m (d); in FCT_mod$8r_m()
1107 FCT_mod$16r_m (struct output_data *d) in FCT_mod$16r_m() argument
1109 assert (d->opoff1 % 8 == 0); in FCT_mod$16r_m()
1110 uint_fast8_t modrm = d->data[d->opoff1 / 8]; in FCT_mod$16r_m()
1111 if ((modrm & 0xc0) == 0xc0) in FCT_mod$16r_m()
1113 assert (d->opoff1 / 8 == d->opoff2 / 8); in FCT_mod$16r_m()
1117 size_t *bufcntp = d->bufcntp; in FCT_mod$16r_m()
1118 if (*bufcntp + 3 > d->bufsize) in FCT_mod$16r_m()
1119 return *bufcntp + 3 - d->bufsize; in FCT_mod$16r_m()
1120 d->bufp[(*bufcntp)++] = '%'; in FCT_mod$16r_m()
1121 memcpy (&d->bufp[*bufcntp], dregs[byte] + 1, sizeof (dregs[0]) - 1); in FCT_mod$16r_m()
1123 return 0; in FCT_mod$16r_m()
1126 return general_mod$r_m (d); in FCT_mod$16r_m()
1132 FCT_mod$64r_m (struct output_data *d) in FCT_mod$64r_m() argument
1134 assert (d->opoff1 % 8 == 0); in FCT_mod$64r_m()
1135 uint_fast8_t modrm = d->data[d->opoff1 / 8]; in FCT_mod$64r_m()
1136 if ((modrm & 0xc0) == 0xc0) in FCT_mod$64r_m()
1138 assert (d->opoff1 / 8 == d->opoff2 / 8); in FCT_mod$64r_m()
1142 size_t *bufcntp = d->bufcntp; in FCT_mod$64r_m()
1143 if (*bufcntp + 4 > d->bufsize) in FCT_mod$64r_m()
1144 return *bufcntp + 4 - d->bufsize; in FCT_mod$64r_m()
1145 char *cp = &d->bufp[*bufcntp]; in FCT_mod$64r_m()
1148 (*d->prefixes & has_rex_b) ? hiregs[byte] : aregs[byte]); in FCT_mod$64r_m()
1149 *bufcntp = cp - d->bufp; in FCT_mod$64r_m()
1150 return 0; in FCT_mod$64r_m()
1153 return general_mod$r_m (d); in FCT_mod$64r_m()
1161 FCT_reg (struct output_data *d) in FCT_reg() argument
1163 uint_fast8_t byte = d->data[d->opoff1 / 8]; in FCT_reg()
1164 assert (d->opoff1 % 8 + 3 <= 8); in FCT_reg()
1165 byte >>= 8 - (d->opoff1 % 8 + 3); in FCT_reg()
1167 int is_16bit = (*d->prefixes & has_data16) != 0; in FCT_reg()
1168 size_t *bufcntp = d->bufcntp; in FCT_reg()
1169 if (*bufcntp + 5 > d->bufsize) in FCT_reg()
1170 return *bufcntp + 5 - d->bufsize; in FCT_reg()
1171 d->bufp[(*bufcntp)++] = '%'; in FCT_reg()
1173 if ((*d->prefixes & has_rex_r) != 0 && !is_16bit) in FCT_reg()
1175 *bufcntp += snprintf (&d->bufp[*bufcntp], d->bufsize - *bufcntp, "r%d", in FCT_reg()
1177 if ((*d->prefixes & has_rex_w) == 0) in FCT_reg()
1178 d->bufp[(*bufcntp)++] = 'd'; in FCT_reg()
1183 memcpy (&d->bufp[*bufcntp], dregs[byte] + is_16bit, 3 - is_16bit); in FCT_reg()
1185 if ((*d->prefixes & has_rex_w) != 0 && !is_16bit) in FCT_reg()
1186 d->bufp[*bufcntp] = 'r'; in FCT_reg()
1190 return 0; in FCT_reg()
1196 FCT_oreg (struct output_data *d) in FCT_oreg() argument
1200 int save_prefixes = *d->prefixes; in FCT_oreg()
1202 *d->prefixes = ((save_prefixes & ~has_rex_r) in FCT_oreg()
1205 int r = FCT_reg (d); in FCT_oreg()
1207 *d->prefixes = save_prefixes; in FCT_oreg()
1215 FCT_reg64 (struct output_data *d) in FCT_reg64() argument
1217 uint_fast8_t byte = d->data[d->opoff1 / 8]; in FCT_reg64()
1218 assert (d->opoff1 % 8 + 3 <= 8); in FCT_reg64()
1219 byte >>= 8 - (d->opoff1 % 8 + 3); in FCT_reg64()
1221 if ((*d->prefixes & has_data16) != 0) in FCT_reg64()
1223 size_t *bufcntp = d->bufcntp; in FCT_reg64()
1224 if (*bufcntp + 5 > d->bufsize) in FCT_reg64()
1225 return *bufcntp + 5 - d->bufsize; in FCT_reg64()
1226 d->bufp[(*bufcntp)++] = '%'; in FCT_reg64()
1228 if ((*d->prefixes & has_rex_r) != 0) in FCT_reg64()
1230 *bufcntp += snprintf (&d->bufp[*bufcntp], d->bufsize - *bufcntp, "r%d", in FCT_reg64()
1232 if ((*d->prefixes & has_rex_w) == 0) in FCT_reg64()
1233 d->bufp[(*bufcntp)++] = 'd'; in FCT_reg64()
1238 memcpy (&d->bufp[*bufcntp], aregs[byte], 3); in FCT_reg64()
1241 return 0; in FCT_reg64()
1246 FCT_reg$w (struct output_data *d) in FCT_reg$w() argument
1248 if (d->data[d->opoff2 / 8] & (1 << (7 - (d->opoff2 & 7)))) in FCT_reg$w()
1249 return FCT_reg (d); in FCT_reg$w()
1251 uint_fast8_t byte = d->data[d->opoff1 / 8]; in FCT_reg$w()
1252 assert (d->opoff1 % 8 + 3 <= 8); in FCT_reg$w()
1253 byte >>= 8 - (d->opoff1 % 8 + 3); in FCT_reg$w()
1256 size_t *bufcntp = d->bufcntp; in FCT_reg$w()
1257 if (*bufcntp + 4 > d->bufsize) in FCT_reg$w()
1258 return *bufcntp + 4 - d->bufsize; in FCT_reg$w()
1260 d->bufp[(*bufcntp)++] = '%'; in FCT_reg$w()
1263 if (*d->prefixes & has_rex) in FCT_reg$w()
1265 if (*d->prefixes & has_rex_r) in FCT_reg$w()
1266 *bufcntp += snprintf (d->bufp + *bufcntp, d->bufsize - *bufcntp, in FCT_reg$w()
1270 char* cp = stpcpy (d->bufp + *bufcntp, rex_8bit[byte]); in FCT_reg$w()
1272 *bufcntp = cp - d->bufp; in FCT_reg$w()
1278 d->bufp[(*bufcntp)++] = "acdb"[byte & 3]; in FCT_reg$w()
1279 d->bufp[(*bufcntp)++] = "lh"[byte >> 2]; in FCT_reg$w()
1281 return 0; in FCT_reg$w()
1287 FCT_oreg$w (struct output_data *d) in FCT_oreg$w() argument
1291 int save_prefixes = *d->prefixes; in FCT_oreg$w()
1293 *d->prefixes = ((save_prefixes & ~has_rex_r) in FCT_oreg$w()
1296 int r = FCT_reg$w (d); in FCT_oreg$w()
1298 *d->prefixes = save_prefixes; in FCT_oreg$w()
1306 FCT_freg (struct output_data *d) in FCT_freg() argument
1308 assert (d->opoff1 / 8 == 1); in FCT_freg()
1309 assert (d->opoff1 % 8 == 5); in FCT_freg()
1310 size_t *bufcntp = d->bufcntp; in FCT_freg()
1311 size_t avail = d->bufsize - *bufcntp; in FCT_freg()
1312 int needed = snprintf (&d->bufp[*bufcntp], avail, "%%st(%" PRIx32 ")", in FCT_freg()
1313 (uint32_t) (d->data[1] & 7)); in FCT_freg()
1317 return 0; in FCT_freg()
1323 FCT_reg16 (struct output_data *d) in FCT_reg16() argument
1325 if (*d->prefixes & has_data16) in FCT_reg16()
1328 *d->prefixes |= has_data16; in FCT_reg16()
1329 return FCT_reg (d); in FCT_reg16()
1335 FCT_sel (struct output_data *d) in FCT_sel() argument
1337 assert (d->opoff1 % 8 == 0); in FCT_sel()
1338 assert (d->opoff1 / 8 == 5); in FCT_sel()
1339 if (*d->param_start + 2 >= d->end) in FCT_sel()
1341 *d->param_start += 2; in FCT_sel()
1342 uint16_t absval = read_2ubyte_unaligned (&d->data[5]); in FCT_sel()
1344 size_t *bufcntp = d->bufcntp; in FCT_sel()
1345 size_t avail = d->bufsize - *bufcntp; in FCT_sel()
1346 int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx16, absval); in FCT_sel()
1350 return 0; in FCT_sel()
1355 FCT_sreg2 (struct output_data *d) in FCT_sreg2() argument
1357 uint_fast8_t byte = d->data[d->opoff1 / 8]; in FCT_sreg2()
1358 assert (d->opoff1 % 8 + 3 <= 8); in FCT_sreg2()
1359 byte >>= 8 - (d->opoff1 % 8 + 2); in FCT_sreg2()
1361 size_t *bufcntp = d->bufcntp; in FCT_sreg2()
1362 char *bufp = d->bufp; in FCT_sreg2()
1363 if (*bufcntp + 3 > d->bufsize) in FCT_sreg2()
1364 return *bufcntp + 3 - d->bufsize; in FCT_sreg2()
1370 return 0; in FCT_sreg2()
1375 FCT_sreg3 (struct output_data *d) in FCT_sreg3() argument
1377 uint_fast8_t byte = d->data[d->opoff1 / 8]; in FCT_sreg3()
1378 assert (d->opoff1 % 8 + 4 <= 8); in FCT_sreg3()
1379 byte >>= 8 - (d->opoff1 % 8 + 3); in FCT_sreg3()
1384 size_t *bufcntp = d->bufcntp; in FCT_sreg3()
1385 char *bufp = d->bufp; in FCT_sreg3()
1386 if (*bufcntp + 3 > d->bufsize) in FCT_sreg3()
1387 return *bufcntp + 3 - d->bufsize; in FCT_sreg3()
1393 return 0; in FCT_sreg3()
1398 FCT_string (struct output_data *d __attribute__ ((unused))) in FCT_string() argument
1400 return 0; in FCT_string()
1405 FCT_xmmreg (struct output_data *d) in FCT_xmmreg() argument
1407 uint_fast8_t byte = d->data[d->opoff1 / 8]; in FCT_xmmreg()
1408 assert (d->opoff1 % 8 == 2 || d->opoff1 % 8 == 5); in FCT_xmmreg()
1409 byte = (byte >> (5 - d->opoff1 % 8)) & 7; in FCT_xmmreg()
1411 size_t *bufcntp = d->bufcntp; in FCT_xmmreg()
1412 size_t avail = d->bufsize - *bufcntp; in FCT_xmmreg()
1413 int needed = snprintf (&d->bufp[*bufcntp], avail, "%%xmm%" PRIxFAST8, byte); in FCT_xmmreg()
1417 return 0; in FCT_xmmreg()