145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * x86 architecture description 345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Copyright (C) 2002-2007 Peter Johnson 545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Redistribution and use in source and binary forms, with or without 745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * modification, are permitted provided that the following conditions 845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * are met: 945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 1. Redistributions of source code must retain the above copyright 1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * notice, this list of conditions and the following disclaimer. 1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 2. Redistributions in binary form must reproduce the above copyright 1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * notice, this list of conditions and the following disclaimer in the 1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * documentation and/or other materials provided with the distribution. 1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' 1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE 1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * POSSIBILITY OF SUCH DAMAGE. 2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 2745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <util.h> 2845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <libyasm.h> 3045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include "x86arch.h" 3245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgyasm_arch_module yasm_x86_LTX_arch; 3545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic /*@only@*/ yasm_arch * 3845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_create(const char *machine, const char *parser, 3945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /*@out@*/ yasm_arch_create_error *error) 4045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 4145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86; 4245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org unsigned int amd64_machine; 4345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 4445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org *error = YASM_ARCH_CREATE_OK; 4545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 4645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (yasm__strcasecmp(machine, "x86") == 0) 4745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org amd64_machine = 0; 4845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else if (yasm__strcasecmp(machine, "amd64") == 0) 4945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org amd64_machine = 1; 5045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else { 5145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org *error = YASM_ARCH_CREATE_BAD_MACHINE; 5245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return NULL; 5345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 5445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86 = yasm_xmalloc(sizeof(yasm_arch_x86)); 5645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->arch.module = &yasm_x86_LTX_arch; 5845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* default to all instructions/features enabled */ 6045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->active_cpu = 0; 6145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->cpu_enables_size = 1; 6245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->cpu_enables = yasm_xmalloc(sizeof(wordptr)); 6345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->cpu_enables[0] = BitVector_Create(64, FALSE); 6445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org BitVector_Fill(arch_x86->cpu_enables[0]); 6545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 6645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->amd64_machine = amd64_machine; 6745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->mode_bits = 0; 6845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->force_strict = 0; 6945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->default_rel = 0; 70a1b5233e6d340f45f4846131fec9d0b92e203ce4hbono@chromium.org arch_x86->gas_intel_mode = 0; 7145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->nop = X86_NOP_BASIC; 7245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 7345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (yasm__strcasecmp(parser, "nasm") == 0) 7445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->parser = X86_PARSER_NASM; 7545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else if (yasm__strcasecmp(parser, "tasm") == 0) 7645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->parser = X86_PARSER_TASM; 7745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else if (yasm__strcasecmp(parser, "gas") == 0 7845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org || yasm__strcasecmp(parser, "gnu") == 0) 7945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->parser = X86_PARSER_GAS; 8045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else { 8145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_xfree(arch_x86); 8245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org *error = YASM_ARCH_CREATE_BAD_PARSER; 8345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return NULL; 8445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 8545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 8645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return (yasm_arch *)arch_x86; 8745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 8845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 8945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 9045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_destroy(/*@only@*/ yasm_arch *arch) 9145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 9245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; 9345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org unsigned int i; 9445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org for (i=0; i<arch_x86->cpu_enables_size; i++) 9545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org BitVector_Destroy(arch_x86->cpu_enables[i]); 9645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_xfree(arch_x86->cpu_enables); 9745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_xfree(arch); 9845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 9945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 10045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic const char * 10145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_get_machine(const yasm_arch *arch) 10245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 10345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org const yasm_arch_x86 *arch_x86 = (const yasm_arch_x86 *)arch; 10445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (arch_x86->amd64_machine) 10545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return "amd64"; 10645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else 10745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return "x86"; 10845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 10945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 11045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic unsigned int 11145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_get_address_size(const yasm_arch *arch) 11245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 11345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org const yasm_arch_x86 *arch_x86 = (const yasm_arch_x86 *)arch; 11445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (arch_x86->mode_bits != 0) 11545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return arch_x86->mode_bits; 11645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (arch_x86->amd64_machine) 11745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 64; 11845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else 11945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 32; 12045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 12145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 12245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic int 12345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_set_var(yasm_arch *arch, const char *var, unsigned long val) 12445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 12545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; 12645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (yasm__strcasecmp(var, "mode_bits") == 0) 12745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->mode_bits = (unsigned int)val; 12845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else if (yasm__strcasecmp(var, "force_strict") == 0) 12945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->force_strict = (unsigned int)val; 13045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else if (yasm__strcasecmp(var, "default_rel") == 0) { 13145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (arch_x86->mode_bits != 64) 13245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_warn_set(YASM_WARN_GENERAL, 13345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org N_("ignoring default rel in non-64-bit mode")); 13445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else 13545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->default_rel = (unsigned int)val; 136a1b5233e6d340f45f4846131fec9d0b92e203ce4hbono@chromium.org } else if (yasm__strcasecmp(var, "gas_intel_mode") == 0) { 137a1b5233e6d340f45f4846131fec9d0b92e203ce4hbono@chromium.org arch_x86->gas_intel_mode = (unsigned int)val; 13845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } else 13945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 1; 14045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 0; 14145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 14245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 14345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 14445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_dir_cpu(yasm_object *object, yasm_valparamhead *valparams, 14545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_valparamhead *objext_valparams, unsigned long line) 14645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 14745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; 14845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 14945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_valparam *vp; 15045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_vps_foreach(vp, valparams) { 15145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /*@null@*/ /*@dependent@*/ const char *s = yasm_vp_string(vp); 15245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (s) 15345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__parse_cpu(arch_x86, s, strlen(s)); 15445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else if (vp->type == YASM_PARAM_EXPR) { 15545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org const yasm_intnum *intcpu; 15645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org intcpu = yasm_expr_get_intnum(&vp->param.e, 0); 15745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (!intcpu) 15845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_error_set(YASM_ERROR_SYNTAX, 15945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org N_("invalid argument to [%s]"), "CPU"); 16045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else { 16145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org char strcpu[16]; 16245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu)); 16345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__parse_cpu(arch_x86, strcpu, strlen(strcpu)); 16445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 16545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } else 16645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_error_set(YASM_ERROR_SYNTAX, N_("invalid argument to [%s]"), 16745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "CPU"); 16845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 16945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 17045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 17145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 17245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_dir_bits(yasm_object *object, yasm_valparamhead *valparams, 17345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_valparamhead *objext_valparams, unsigned long line) 17445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 17545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; 17645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_valparam *vp; 17745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /*@only@*/ /*@null@*/ yasm_expr *e = NULL; 17845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org const yasm_intnum *intn; 17945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org long lval; 18045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 18145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if ((vp = yasm_vps_first(valparams)) && !vp->val && 18245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org (e = yasm_vp_expr(vp, object->symtab, line)) != NULL && 18345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org (intn = yasm_expr_get_intnum(&e, 0)) != NULL && 18445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org (lval = yasm_intnum_get_int(intn)) && 18545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org (lval == 16 || lval == 32 || lval == 64)) 18645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->mode_bits = (unsigned char)lval; 18745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else 18845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_error_set(YASM_ERROR_VALUE, N_("invalid argument to [%s]"), 18945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "BITS"); 19045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (e) 19145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_expr_destroy(e); 19245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 19345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 19445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 19545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_dir_code16(yasm_object *object, yasm_valparamhead *valparams, 19645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_valparamhead *objext_valparams, unsigned long line) 19745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 19845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; 19945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->mode_bits = 16; 20045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 20145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 20245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 20345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_dir_code32(yasm_object *object, yasm_valparamhead *valparams, 20445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_valparamhead *objext_valparams, unsigned long line) 20545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 20645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; 20745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->mode_bits = 32; 20845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 20945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 21045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 21145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_dir_code64(yasm_object *object, yasm_valparamhead *valparams, 21245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_valparamhead *objext_valparams, unsigned long line) 21345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 21445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; 21545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org arch_x86->mode_bits = 64; 21645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 21745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 21845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic const unsigned char ** 21945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_get_fill(const yasm_arch *arch) 22045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 22145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org const yasm_arch_x86 *arch_x86 = (const yasm_arch_x86 *)arch; 22245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 22345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* Fill patterns that GAS uses. */ 22445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_1[1] = 22545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x90}; /* 1 - nop */ 22645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_2[2] = 22745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x89, 0xf6}; /* 2 - mov si, si */ 22845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_3[3] = 22945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0x74, 0x00}; /* 3 - lea si, [si+byte 0] */ 23045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_4[4] = 23145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0xb4, 0x00, 0x00}; /* 4 - lea si, [si+word 0] */ 23245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_5[5] = 23345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x90, /* 5 - nop */ 23445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xb4, 0x00, 0x00}; /* lea si, [si+word 0] */ 23545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_6[6] = 23645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x89, 0xf6, /* 6 - mov si, si */ 23745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbd, 0x00, 0x00}; /* lea di, [di+word 0] */ 23845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_7[7] = 23945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0x74, 0x00, /* 7 - lea si, [si+byte 0] */ 24045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbd, 0x00, 0x00}; /* lea di, [di+word 0] */ 24145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_8[8] = 24245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0xb4, 0x00, 0x00, /* 8 - lea si, [si+word 0] */ 24345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbd, 0x00, 0x00}; /* lea di, [di+word 0] */ 24445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_9[9] = 24545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x07, 0x90, 0x90, 0x90, 0x90, /* 9 - jmp $+9; nop fill */ 24645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90}; 24745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_10[10] = 24845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x08, 0x90, 0x90, 0x90, 0x90, /* 10 - jmp $+10; nop fill */ 24945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90}; 25045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_11[11] = 25145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x09, 0x90, 0x90, 0x90, 0x90, /* 11 - jmp $+11; nop fill */ 25245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90}; 25345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_12[12] = 25445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x0a, 0x90, 0x90, 0x90, 0x90, /* 12 - jmp $+12; nop fill */ 25545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; 25645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_13[13] = 25745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x0b, 0x90, 0x90, 0x90, 0x90, /* 13 - jmp $+13; nop fill */ 25845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; 25945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_14[14] = 26045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x0c, 0x90, 0x90, 0x90, 0x90, /* 14 - jmp $+14; nop fill */ 26145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; 26245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill16_15[15] = 26345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x0d, 0x90, 0x90, 0x90, 0x90, /* 15 - jmp $+15; nop fill */ 26445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; 26545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char *fill16[16] = 26645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { 26745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org NULL, fill16_1, fill16_2, fill16_3, 26845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill16_4, fill16_5, fill16_6, fill16_7, 26945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill16_8, fill16_9, fill16_10, fill16_11, 27045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill16_12, fill16_13, fill16_14, fill16_15 27145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org }; 27245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 27345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_1[1] = 27445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x90}; /* 1 - nop */ 27545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_2[2] = 27645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x90}; /* 2 - xchg ax, ax (o16 nop) */ 27745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_3[3] = 27845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0x76, 0x00}; /* 3 - lea esi, [esi+byte 0] */ 27945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_4[4] = 28045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0x74, 0x26, 0x00}; /* 4 - lea esi, [esi*1+byte 0] */ 28145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_5[5] = 28245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x90, /* 5 - nop */ 28345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0x74, 0x26, 0x00}; /* lea esi, [esi*1+byte 0] */ 28445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_6[6] = 28545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0xb6, 0x00, 0x00, 0x00, 0x00};/* 6 - lea esi, [esi+dword 0] */ 28645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_7[7] = 28745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0xb4, 0x26, 0x00, 0x00, 0x00, /* 7 - lea esi, [esi*1+dword 0] */ 28845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00}; 28945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_8[8] = 29045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x90, /* 8 - nop */ 29145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xb4, 0x26, 0x00, 0x00, 0x00, /* lea esi, [esi*1+dword 0] */ 29245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00}; 29345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#if 0 29445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* GAS uses these */ 29545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_9[9] = 29645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x89, 0xf6, /* 9 - mov esi, esi */ 29745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi*1+dword 0] */ 29845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00}; 29945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_10[10] = 30045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0x76, 0x00, /* 10 - lea esi, [esi+byte 0] */ 30145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi+dword 0] */ 30245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00}; 30345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_11[11] = 30445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0x74, 0x26, 0x00, /* 11 - lea esi, [esi*1+byte 0] */ 30545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi*1+dword 0] */ 30645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00}; 30745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_12[12] = 30845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0xb6, 0x00, 0x00, 0x00, 0x00, /* 12 - lea esi, [esi+dword 0] */ 30945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbf, 0x00, 0x00, 0x00, 0x00};/* lea edi, [edi+dword 0] */ 31045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_13[13] = 31145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0xb6, 0x00, 0x00, 0x00, 0x00, /* 13 - lea esi, [esi+dword 0] */ 31245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi*1+dword 0] */ 31345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00}; 31445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_14[14] = 31545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x8d, 0xb4, 0x26, 0x00, 0x00, 0x00, /* 14 - lea esi, [esi*1+dword 0] */ 31645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00, 31745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi*1+dword 0] */ 31845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00}; 31945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#else 32045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* But on newer processors, these are recommended */ 32145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_9[9] = 32245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x07, 0x90, 0x90, 0x90, 0x90, /* 9 - jmp $+9; nop fill */ 32345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90}; 32445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_10[10] = 32545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x08, 0x90, 0x90, 0x90, 0x90, /* 10 - jmp $+10; nop fill */ 32645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90}; 32745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_11[11] = 32845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x09, 0x90, 0x90, 0x90, 0x90, /* 11 - jmp $+11; nop fill */ 32945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90}; 33045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_12[12] = 33145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x0a, 0x90, 0x90, 0x90, 0x90, /* 12 - jmp $+12; nop fill */ 33245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; 33345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_13[13] = 33445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x0b, 0x90, 0x90, 0x90, 0x90, /* 13 - jmp $+13; nop fill */ 33545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; 33645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_14[14] = 33745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x0c, 0x90, 0x90, 0x90, 0x90, /* 14 - jmp $+14; nop fill */ 33845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; 33945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 34045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32_15[15] = 34145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0xeb, 0x0d, 0x90, 0x90, 0x90, 0x90, /* 15 - jmp $+15; nop fill */ 34245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; 34345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char *fill32[16] = 34445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { 34545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org NULL, fill32_1, fill32_2, fill32_3, 34645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32_4, fill32_5, fill32_6, fill32_7, 34745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32_8, fill32_9, fill32_10, fill32_11, 34845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32_12, fill32_13, fill32_14, fill32_15 34945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org }; 35045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 35145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* Long form nops available on more recent Intel and AMD processors */ 35245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32new_3[3] = 35345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x0f, 0x1f, 0x00}; /* 3 - nop(3) */ 35445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32new_4[4] = 35545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x0f, 0x1f, 0x40, 0x00}; /* 4 - nop(4) */ 35645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32new_5[5] = 35745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x0f, 0x1f, 0x44, 0x00, 0x00}; /* 5 - nop(5) */ 35845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32new_6[6] = 35945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00}; /* 6 - nop(6) */ 36045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32new_7[7] = 36145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00}; /* 7 - nop(7) */ 36245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32new_8[8] = 36345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, /* 8 - nop(8) */ 36445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00}; 36545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32new_9[9] = 36645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, /* 9 - nop(9) */ 36745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00, 0x00}; 36845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 36945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* Longer forms preferred by Intel use repeated o16 prefixes */ 37045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32intel_10[10] = 37145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, /* 10 - o16; cs; nop */ 37245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00, 0x00, 0x00}; 37345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32intel_11[11] = 37445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, /* 11 - 2x o16; cs; nop */ 37545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00, 0x00, 0x00, 0x00}; 37645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32intel_12[12] = 37745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, /* 12 - 3x o16; cs; nop */ 37845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00, 0x00, 0x00, 0x00, 0x00}; 37945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32intel_13[13] = 38045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x66, 0x66, 0x66, 0x2e, 0x0f, 0x1f, /* 13 - 4x o16; cs; nop */ 38145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}; 38245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32intel_14[14] = 38345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x66, 0x66, 0x66, 0x66, 0x2e, 0x0f, /* 14 - 5x o16; cs; nop */ 38445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}; 38545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32intel_15[15] = 38645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x2e, /* 15 - 6x o16; cs; nop */ 38745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}; 38845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 38945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* Longer forms preferred by AMD use fewer o16 prefixes and no CS prefix; 39045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Source: Software Optimisation Guide for AMD Family 10h 39145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Processors 40546 revision 3.10 February 2009 39245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 39345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32amd_10[10] = 39445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, /* 10 - nop(10) */ 39545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x00, 0x00, 0x00}; 39645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32amd_11[11] = 39745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x0f, 0x1f, 0x44, 0x00, 0x00, /* 11 - nop(5) */ 39845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00}; /* nop(6) */ 39945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32amd_12[12] = 40045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00, /* 12 - nop(6) */ 40145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00}; /* nop(6) */ 40245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32amd_13[13] = 40345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00, /* 13 - nop(6) */ 40445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00}; /* nop(7) */ 40545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32amd_14[14] = 40645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, /* 14 - nop(7) */ 40745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00}; /* nop(7) */ 40845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char fill32amd_15[15] = 40945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org {0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, /* 15 - nop(7) */ 41045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}; /* nop(8) */ 41145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 41245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char *fill32_intel[16] = 41345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { 41445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org NULL, fill32_1, fill32_2, fill32new_3, 41545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32new_4, fill32new_5, fill32new_6, fill32new_7, 41645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32new_8, fill32new_9, fill32intel_10, fill32intel_11, 41745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32intel_12, fill32intel_13, fill32intel_14, fill32intel_15 41845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org }; 41945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const unsigned char *fill32_amd[16] = 42045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { 42145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org NULL, fill32_1, fill32_2, fill32new_3, 42245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32new_4, fill32new_5, fill32new_6, fill32new_7, 42345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32new_8, fill32new_9, fill32amd_10, fill32amd_11, 42445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fill32amd_12, fill32amd_13, fill32amd_14, fill32amd_15 42545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org }; 42645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 42745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org switch (arch_x86->mode_bits) { 42845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case 16: 42945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return fill16; 43045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case 32: 43145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (arch_x86->nop == X86_NOP_INTEL) 43245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return fill32_intel; 43345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else if (arch_x86->nop == X86_NOP_AMD) 43445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return fill32_amd; 43545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else 43645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return fill32; 43745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case 64: 43845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* We know long nops are available in 64-bit mode; default to Intel 43945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ones if unspecified (to match GAS behavior). 44045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 44145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (arch_x86->nop == X86_NOP_AMD) 44245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return fill32_amd; 44345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else 44445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return fill32_intel; 44545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org default: 44645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_error_set(YASM_ERROR_VALUE, 44745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org N_("Invalid mode_bits in x86_get_fill")); 44845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return NULL; 44945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 45045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 45145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 45245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgunsigned int 45345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgyasm_x86__get_reg_size(uintptr_t reg) 45445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 45545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org switch ((x86_expritem_reg_size)(reg & ~0xFUL)) { 45645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG8: 45745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG8X: 45845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 8; 45945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG16: 46045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 16; 46145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG32: 46245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_CRREG: 46345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_DRREG: 46445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_TRREG: 46545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 32; 46645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG64: 46745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_MMXREG: 46845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 64; 46945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_XMMREG: 47045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 128; 47145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_YMMREG: 47245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 256; 47345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_FPUREG: 47445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 80; 47545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org default: 47645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_error_set(YASM_ERROR_VALUE, N_("unknown register size")); 47745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 47845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 0; 47945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 48045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 48145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic unsigned int 48245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_get_reg_size(yasm_arch *arch, uintptr_t reg) 48345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 48445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return yasm_x86__get_reg_size(reg); 48545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 48645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 48745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic uintptr_t 48845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_reggroup_get_reg(yasm_arch *arch, uintptr_t reggroup, 48945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org unsigned long regindex) 49045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 49145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; 49245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org switch ((x86_expritem_reg_size)(reggroup & ~0xFUL)) { 49345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_XMMREG: 49445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_YMMREG: 49545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (arch_x86->mode_bits == 64) { 49645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (regindex > 15) 49745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 0; 49845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return reggroup | (regindex & 15); 49945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 50045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /*@fallthrough@*/ 50145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_MMXREG: 50245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_FPUREG: 50345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if (regindex > 7) 50445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 0; 50545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return reggroup | (regindex & 7); 50645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org default: 50745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_error_set(YASM_ERROR_VALUE, N_("bad register group")); 50845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 50945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return 0; 51045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 51145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 51245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 51345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_reg_print(yasm_arch *arch, uintptr_t reg, FILE *f) 51445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 51545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const char *name8[] = {"al","cl","dl","bl","ah","ch","dh","bh"}; 51645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const char *name8x[] = { 51745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", 51845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" 51945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org }; 52045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const char *name16[] = { 52145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", 52245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" 52345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org }; 52445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const char *name32[] = { 52545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", 52645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" 52745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org }; 52845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const char *name64[] = { 52945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", 53045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" 53145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org }; 53245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 53345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org switch ((x86_expritem_reg_size)(reg & ~0xFUL)) { 53445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG8: 53545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "%s", name8[reg&0xF]); 53645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 53745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG8X: 53845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "%s", name8x[reg&0xF]); 53945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 54045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG16: 54145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "%s", name16[reg&0xF]); 54245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 54345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG32: 54445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "%s", name32[reg&0xF]); 54545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 54645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_REG64: 54745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "%s", name64[reg&0xF]); 54845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 54945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_MMXREG: 55045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "mm%d", (int)(reg&0xF)); 55145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 55245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_XMMREG: 55345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "xmm%d", (int)(reg&0xF)); 55445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 55545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_YMMREG: 55645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "ymm%d", (int)(reg&0xF)); 55745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 55845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_CRREG: 55945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "cr%d", (int)(reg&0xF)); 56045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 56145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_DRREG: 56245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "dr%d", (int)(reg&0xF)); 56345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 56445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_TRREG: 56545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "tr%d", (int)(reg&0xF)); 56645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 56745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org case X86_FPUREG: 56845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "st%d", (int)(reg&0xF)); 56945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break; 57045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org default: 57145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_error_set(YASM_ERROR_VALUE, N_("unknown register size")); 57245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 57345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 57445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 57545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 57645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86_segreg_print(yasm_arch *arch, uintptr_t segreg, FILE *f) 57745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 57845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org static const char *name[] = {"es","cs","ss","ds","fs","gs"}; 57945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fprintf(f, "%s", name[segreg&7]); 58045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 58145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 58245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* Define x86 machines -- see arch.h for details */ 58345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic const yasm_arch_machine x86_machines[] = { 58445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { "IA-32 and derivatives", "x86" }, 58545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { "AMD64", "amd64" }, 58645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { NULL, NULL } 58745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org}; 58845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 58945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic const yasm_directive x86_directives[] = { 59045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { "cpu", "nasm", x86_dir_cpu, YASM_DIR_ARG_REQUIRED }, 59145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { "bits", "nasm", x86_dir_bits, YASM_DIR_ARG_REQUIRED }, 59245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { ".code16", "gas", x86_dir_code16, YASM_DIR_ANY }, 59345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { ".code32", "gas", x86_dir_code32, YASM_DIR_ANY }, 59445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { ".code64", "gas", x86_dir_code64, YASM_DIR_ANY }, 59545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org { NULL, NULL, NULL, 0 } 59645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org}; 59745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 59845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* Define arch structure -- see arch.h for details */ 59945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgyasm_arch_module yasm_x86_LTX_arch = { 60045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "x86 (IA-32 and derivatives), AMD64", 60145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "x86", 60245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_directives, 60345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_create, 60445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_destroy, 60545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_get_machine, 60645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_get_address_size, 60745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_set_var, 60845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__parse_check_insnprefix, 60945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__parse_check_regtmod, 61045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_get_fill, 61145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__floatnum_tobytes, 61245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__intnum_tobytes, 61345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_get_reg_size, 61445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_reggroup_get_reg, 61545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_reg_print, 61645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_segreg_print, 61745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__ea_create_expr, 61845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__ea_destroy, 61945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__ea_print, 62045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_x86__create_empty_insn, 62145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org x86_machines, 62245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "x86", 62345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 16, 62445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1 62545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org}; 626