chromium/third_party/nasm/disasm/disasm.c

/* ----------------------------------------------------------------------- *
 *   
 *   Copyright 1996-2012 The NASM Authors - All Rights Reserved
 *   See the file AUTHORS included with the NASM distribution for
 *   the specific copyright holders.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following
 *   conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *     
 *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ----------------------------------------------------------------------- */

/* 
 * disasm.c   where all the _work_ gets done in the Netwide Disassembler
 */

#include "compiler.h"


#include "nasm.h"
#include "disasm.h"
#include "sync.h"
#include "insns.h"
#include "tables.h"
#include "regdis.h"
#include "disp8.h"

#define fetch_safe(_start, _ptr, _size, _need, _op)

#define fetch_or_return(_start, _ptr, _size, _need)

/*
 * Flags that go into the `segment' field of `insn' structures
 * during disassembly.
 */
#define SEG_RELATIVE
#define SEG_32BIT
#define SEG_RMREG
#define SEG_DISP8
#define SEG_DISP16
#define SEG_DISP32
#define SEG_NODISP
#define SEG_SIGNED
#define SEG_64BIT

/*
 * Prefix information
 */
struct prefix_info {};

#define getu8(x)
#if X86_MEMORY
/* Littleendian CPU which can handle unaligned references */
#define getu16(x)
#define getu32(x)
#define getu64(x)
#else
static uint16_t getu16(uint8_t *data)
{
    return (uint16_t)data[0] + ((uint16_t)data[1] << 8);
}
static uint32_t getu32(uint8_t *data)
{
    return (uint32_t)getu16(data) + ((uint32_t)getu16(data+2) << 16);
}
static uint64_t getu64(uint8_t *data)
{
    return (uint64_t)getu32(data) + ((uint64_t)getu32(data+4) << 32);
}
#endif

#define gets8(x)
#define gets16(x)
#define gets32(x)
#define gets64(x)

/* Important: regval must already have been adjusted for rex extensions */
static enum reg_enum whichreg(opflags_t regflags, int regval, int rex)
{}

static uint32_t append_evex_reg_deco(char *buf, uint32_t num,
                                    decoflags_t deco, uint8_t *evex)
{}

static uint32_t append_evex_mem_deco(char *buf, uint32_t num, opflags_t type,
                                     decoflags_t deco, uint8_t *evex)
{}

/*
 * Process an effective address (ModRM) specification.
 */
static uint8_t *do_ea(uint8_t *data, int modrm, int asize,
                      int segsize, enum ea_type type,
                      operand *op, insn *ins)
{}

/*
 * Determine whether the instruction template in t corresponds to the data
 * stream in data. Return the number of bytes matched if so.
 */
#define case4(x)

static int matches(const struct itemplate *t, uint8_t *data,
                   const struct prefix_info *prefix, int segsize, insn *ins)
{}

/* Condition names for disassembly, sorted by x86 code */
static const char * const condition_name[16] =;

int32_t disasm(uint8_t *data, int32_t data_size, char *output, int outbufsize, int segsize,
               int64_t offset, int autosync, iflag_t *prefer)
{}

/*
 * This is called when we don't have a complete instruction.  If it
 * is a standalone *single-byte* prefix show it as such, otherwise
 * print it as a literal.
 */
int32_t eatbyte(uint8_t *data, char *output, int outbufsize, int segsize)
{}