diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-03-31 21:43:25 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-03-31 21:43:25 +0000 |
commit | 5d0734a7d74cf01b73303aeb884b719b4b220035 (patch) | |
tree | f24aaaf513a030c64dd9b0dae5ddb405a1c214f3 /opcodes/z8k-dis.c | |
parent | 79337c85b8e706bd247a99d26a237f6dddf4ffe5 (diff) | |
download | gdb-5d0734a7d74cf01b73303aeb884b719b4b220035.zip gdb-5d0734a7d74cf01b73303aeb884b719b4b220035.tar.gz gdb-5d0734a7d74cf01b73303aeb884b719b4b220035.tar.bz2 |
provide a new interface (using read_memory_func) to call the disassemblers
which copes with errors in a plausible way
Diffstat (limited to 'opcodes/z8k-dis.c')
-rw-r--r-- | opcodes/z8k-dis.c | 940 |
1 files changed, 495 insertions, 445 deletions
diff --git a/opcodes/z8k-dis.c b/opcodes/z8k-dis.c index 2a2d3c3..d296f64 100644 --- a/opcodes/z8k-dis.c +++ b/opcodes/z8k-dis.c @@ -1,33 +1,111 @@ -#include <stdio.h> +/* +This file is part of GNU Binutils. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <ansidecl.h> +#include "sysdep.h" +#include "dis-asm.h" + #define DEFINE_TABLE #include "z8k-opc.h" -static void fetch_data(); -static void fetch_instr(); -static unsigned long get_val(); -static int is_segmented(); -static int lookup_instr(); -static void output_instr(); -static void unpack_instr(); -static void unparse_instr(); - -typedef struct { - unsigned char instr_buf[24]; - unsigned long bytes_fetched; - unsigned long tabl_index; - char instr_asmsrc[80]; - unsigned long arg_reg[0x0f]; - unsigned long immediate; - unsigned long displacement; - unsigned long address; - unsigned long cond_code; - unsigned long ctrl_code; - unsigned long flags; - unsigned long interrupts; -} instr_data_s; - - -static char *codes[16] = + +#include <setjmp.h> + + +typedef struct +{ + /* These are all indexed by nibble number (i.e only every other entry + of bytes is used, and every 4th entry of words). */ + unsigned char nibbles[24]; + unsigned char bytes[24]; + unsigned short words[24]; + + /* Nibble number of first word not yet fetched. */ + int max_fetched; + bfd_vma insn_start; + jmp_buf bailout; + + long tabl_index; + char instr_asmsrc[80]; + unsigned long arg_reg[0x0f]; + unsigned long immediate; + unsigned long displacement; + unsigned long address; + unsigned long cond_code; + unsigned long ctrl_code; + unsigned long flags; + unsigned long interrupts; +} +instr_data_s; + +/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive) + to ADDR (exclusive) are valid. Returns 1 for success, longjmps + on error. */ +#define FETCH_DATA(info, nibble) \ + ((nibble) <= ((instr_data_s *)(info->private_data))->max_fetched \ + ? 1 : fetch_data ((info), (nibble))) + +static int +fetch_data (info, nibble) + struct disassemble_info *info; + int nibble; +{ + char mybuf[20]; + int status; + instr_data_s *priv = (instr_data_s *)info->private_data; + bfd_vma start = priv->insn_start + priv->max_fetched / 2; + + if ((nibble % 4) != 0) + abort (); + status = (*info->read_memory_func) (start, + mybuf, + (nibble - priv->max_fetched) / 2, + info); + if (status != 0) + { + (*info->memory_error_func) (status, start, info); + longjmp (priv->bailout); + } + + { + int i; + char *p = mybuf + priv->max_fetched / 2; + + for (i = priv->max_fetched; i < nibble;) + { + priv->words[i] = (p[0] << 8) | p[1]; + + priv->bytes[i] = *p; + priv->nibbles[i++] = *p >> 4; + priv->nibbles[i++] = *p &0xf; + + ++p; + priv->bytes[i] = *p; + priv->nibbles[i++] = *p >> 4; + priv->nibbles[i++] = *p & 0xf; + + ++p; + } + } + priv->max_fetched = nibble; + return 1; +} + +static char *codes[16] = { "f", "lt", @@ -47,473 +125,445 @@ static char *codes[16] = "nc/uge" }; - -int print_insn_z8k(addr, in_buf, stream) -unsigned long addr; -unsigned char *in_buf; -FILE *stream; +int z8k_lookup_instr PARAMS ((unsigned char*, disassemble_info *)); +static void output_instr + PARAMS ((instr_data_s *, unsigned long, disassemble_info *)); +static void unpack_instr PARAMS ((instr_data_s *, int, disassemble_info *)); +static void unparse_instr PARAMS ((instr_data_s *)); + +static int +print_insn_z8k (addr, info, is_segmented) + unsigned long addr; + disassemble_info *info; + int is_segmented; { - instr_data_s instr_data; + instr_data_s instr_data; - fetch_instr( &in_buf, &instr_data ); - if ( lookup_instr( &instr_data )) - { - fetch_data( &in_buf, &instr_data ); - unpack_instr( &instr_data ); - unparse_instr( &instr_data ); - output_instr( &instr_data, addr, stream ); - return instr_data.bytes_fetched; - } - else { - fprintf(stream,".word %02x%02x", in_buf[0], in_buf[1]); - return 2; - } - -} - - -static void fetch_data( in_buf, instr_data ) -unsigned char **in_buf; -instr_data_s *instr_data; -{ - int bytes_2fetch; - - bytes_2fetch = z8k_table[instr_data->tabl_index].length - - instr_data->bytes_fetched; - while( bytes_2fetch-- ) - instr_data->instr_buf[instr_data->bytes_fetched++] = *(*in_buf)++; -} - -static void fetch_instr( in_buf, instr_data ) -unsigned char **in_buf; -instr_data_s *instr_data; -{ - unsigned int loop = 2; - - instr_data->bytes_fetched = 0; - while( loop-- ) - instr_data->instr_buf[instr_data->bytes_fetched++] = *(*in_buf)++; + info->private_data = (PTR) &instr_data; + instr_data.max_fetched = 0; + instr_data.insn_start = addr; + if (setjmp (instr_data.bailout) != 0) + /* Error return. */ + return -1; + instr_data.tabl_index = z8k_lookup_instr (instr_data.nibbles, info); + if (instr_data.tabl_index > 0) + { + unpack_instr (&instr_data, is_segmented, info); + unparse_instr (&instr_data); + output_instr (&instr_data, addr, info); + return z8k_table[instr_data.tabl_index].length; + } + else + { + FETCH_DATA (info, 4); + (*info->fprintf_func) (info->stream, ".word %02x%02x", + instr_data.bytes[0], instr_data.bytes[2]); + return 2; + } } -static unsigned long get_val( instr_buf, start_nibl, nibls_long ) -unsigned char (*instr_buf)[]; -unsigned int start_nibl, nibls_long; +print_insn_z8001 (addr, info) + unsigned long addr; + disassemble_info *info; { - unsigned long ret_val; - unsigned char byte_val, nibl_val; - unsigned int nibl_index, nibl_lim; - unsigned int byte_index; - unsigned int which_nibl; - - ret_val = 0; - nibl_lim = start_nibl + nibls_long; - for( nibl_index = start_nibl; nibl_index < nibl_lim; nibl_index++ ) - { - byte_index = nibl_index / 2; - which_nibl = nibl_index % 2; - switch( which_nibl ) - { - case 0: - byte_val = (*instr_buf)[byte_index]; - nibl_val = (byte_val >> 4) & 0x0f; - break; - case 1: - nibl_val = byte_val & 0x0f; - break; - } - ret_val = (ret_val << 4) | nibl_val; - } - - return ret_val; - + return print_insn_z8k (addr, info, 1); } -static int is_segmented() +print_insn_z8002 (addr, info) + unsigned long addr; + disassemble_info *info; { - return 1; + return print_insn_z8k (addr, info, 0); } -static -int lookup_instr( instr_data ) -instr_data_s *instr_data; +int +z8k_lookup_instr (nibbles, info) + unsigned char *nibbles; + disassemble_info *info; { - int nibl_index, tabl_index; - int tablent_found, nibl_matched; + int nibl_index, tabl_index; + int nibl_matched; unsigned short instr_nibl; unsigned short tabl_datum, datum_class, datum_value; nibl_matched = 0; tabl_index = 0; - while( ! nibl_matched && z8k_table[tabl_index].name) - { - nibl_matched = 1; - for( nibl_index = 0; nibl_index < 4 && nibl_matched; nibl_index++ ) + while (!nibl_matched && z8k_table[tabl_index].name) { - instr_nibl = get_val( instr_data->instr_buf, nibl_index, 1 ); - - tabl_datum = z8k_table[tabl_index].byte_info[nibl_index]; - datum_class = tabl_datum & CLASS_MASK; - datum_value = ~CLASS_MASK & tabl_datum; - - switch( datum_class ) - { - case CLASS_BIT: - if( datum_value != instr_nibl ) nibl_matched = 0; - break; - case CLASS_00II: - if( ! ((~instr_nibl) & 0x4) ) nibl_matched = 0; - break; - case CLASS_01II: - if( ! (instr_nibl & 0x4) ) nibl_matched = 0; - break; - case CLASS_0CCC: - if( ! ((~instr_nibl) & 0x8) ) nibl_matched = 0; - break; - case CLASS_1CCC: - if( ! (instr_nibl & 0x8) ) nibl_matched = 0; - break; - case CLASS_0DISP7: - if( ! ((~instr_nibl) & 0x8) ) nibl_matched = 0; - nibl_index += 1; - break; - case CLASS_1DISP7: - if( ! (instr_nibl & 0x8) ) nibl_matched = 0; - nibl_index += 1; - break; - case CLASS_REGN0: - if( instr_nibl == 0 ) nibl_matched = 0; - break; - default: - break; - } + nibl_matched = 1; + for (nibl_index = 0; nibl_index < z8k_table[tabl_index].length * 2 && nibl_matched; nibl_index++) + { + if ((nibl_index % 4) == 0) + /* Fetch one word at a time. */ + FETCH_DATA (info, nibl_index + 4); + instr_nibl = nibbles[nibl_index]; + + tabl_datum = z8k_table[tabl_index].byte_info[nibl_index]; + datum_class = tabl_datum & CLASS_MASK; + datum_value = ~CLASS_MASK & tabl_datum; + + switch (datum_class) + { + case CLASS_BIT: + if (datum_value != instr_nibl) + nibl_matched = 0; + break; + case CLASS_00II: + if (!((~instr_nibl) & 0x4)) + nibl_matched = 0; + break; + case CLASS_01II: + if (!(instr_nibl & 0x4)) + nibl_matched = 0; + break; + case CLASS_0CCC: + if (!((~instr_nibl) & 0x8)) + nibl_matched = 0; + break; + case CLASS_1CCC: + if (!(instr_nibl & 0x8)) + nibl_matched = 0; + break; + case CLASS_0DISP7: + if (!((~instr_nibl) & 0x8)) + nibl_matched = 0; + nibl_index += 1; + break; + case CLASS_1DISP7: + if (!(instr_nibl & 0x8)) + nibl_matched = 0; + nibl_index += 1; + break; + case CLASS_REGN0: + if (instr_nibl == 0) + nibl_matched = 0; + break; + case CLASS_BIT_1OR2: + if ((instr_nibl | 0x2) != (datum_value | 0x2)) + nibl_matched = 0; + break; + default: + break; + } + } + if (nibl_matched) + { + return tabl_index; + } + + tabl_index++; } - tabl_index++; - } - - - instr_data->tabl_index = tabl_index; - - return nibl_matched; + return -1; } -static void output_instr( instr_data, addr, stream ) -instr_data_s *instr_data; -unsigned long addr; -FILE *stream; +static void +output_instr (instr_data, addr, info) + instr_data_s *instr_data; + unsigned long addr; + disassemble_info *info; { - int loop, loop_limit; - unsigned long word_val; - char tmp_str[20]; - char out_str[100]; + int loop, loop_limit; + char tmp_str[20]; + char out_str[100]; - strcpy( out_str, "" ); + strcpy (out_str, "\t"); - loop_limit = z8k_table[instr_data->tabl_index].length / 2; - for( loop = 0; loop < loop_limit; loop++ ) - { - word_val = get_val( instr_data->instr_buf, loop * 4, 4 ); - sprintf( tmp_str, "%04x ", word_val ); - strcat( out_str, tmp_str ); - } + loop_limit = z8k_table[instr_data->tabl_index].length * 2; + FETCH_DATA (info, loop_limit); + for (loop = 0; loop < loop_limit; loop++) + { + sprintf (tmp_str, "%x", instr_data->nibbles[loop]); + strcat (out_str, tmp_str); + } - while( loop++ < 5 ) - { - strcat( out_str, " " ); - } + while (loop++ < 8) + { + strcat (out_str, " "); + } - strcat( out_str, instr_data->instr_asmsrc ); + strcat (out_str, instr_data->instr_asmsrc); - fprintf( stream, "%s", out_str ); + (*info->fprintf_func) (info->stream, "%s", out_str); } -static void unpack_instr( instr_data ) -instr_data_s *instr_data; +static void +unpack_instr (instr_data, is_segmented, info) + instr_data_s *instr_data; + int is_segmented; + disassemble_info *info; { - int nibl_index, word_index; - int nibl_count, loop; - unsigned short instr_nibl, instr_byte, instr_word, instr_long; - unsigned short tabl_datum, datum_class, datum_value; - - nibl_count = 0; - loop = 0; - while( z8k_table[instr_data->tabl_index].byte_info[loop] != 0 ) - { - word_index = (int) nibl_count / 4; - nibl_index = (int) nibl_count % 4; - - switch( nibl_index ) - { - case 0: - instr_nibl = get_val( instr_data->instr_buf, nibl_count, 1 ); - instr_byte = get_val( instr_data->instr_buf, nibl_count, 2 ); - instr_word = get_val( instr_data->instr_buf, nibl_count, 4 ); - instr_long = get_val( instr_data->instr_buf, nibl_count, 8 ); - break; - case 1: - instr_nibl = get_val( instr_data->instr_buf, nibl_count, 1 ); - break; - case 2: - instr_nibl = get_val( instr_data->instr_buf, nibl_count, 1 ); - instr_byte = get_val( instr_data->instr_buf, nibl_count, 2 ); - break; - case 3: - instr_nibl = get_val( instr_data->instr_buf, nibl_count, 1 ); - break; - default: - break; - } + int nibl_count, loop; + unsigned short instr_nibl, instr_byte, instr_word; + long instr_long; + unsigned short tabl_datum, datum_class, datum_value; + + nibl_count = 0; + loop = 0; + while (z8k_table[instr_data->tabl_index].byte_info[loop] != 0) + { + FETCH_DATA (info, nibl_count + 4 - (nibl_count % 4)); + instr_nibl = instr_data->nibbles[nibl_count]; + instr_byte = instr_data->bytes[nibl_count]; + instr_word = instr_data->words[nibl_count]; tabl_datum = z8k_table[instr_data->tabl_index].byte_info[loop]; datum_class = tabl_datum & CLASS_MASK; datum_value = tabl_datum & ~CLASS_MASK; - switch( datum_class ) - { - case CLASS_X: - instr_data->address = instr_nibl; - break; - case CLASS_BA: - instr_data->displacement = instr_nibl; - break; - case CLASS_BX: - instr_data->arg_reg[datum_value] = instr_nibl; - break; - case CLASS_DISP: - switch( datum_value ) - { - case ARG_DISP16: - instr_data->displacement = instr_word; - nibl_count += 3; - break; - case ARG_DISP12: - instr_data->displacement = instr_word & 0x0fff; - nibl_count += 2; - break; - default: - break; - } - break; - case CLASS_IMM: - switch( datum_value ) - { - case ARG_IMM4: - instr_data->immediate = instr_nibl; - break; - case ARG_IMM8: - instr_data->immediate = instr_byte; - nibl_count += 1; - break; - case ARG_IMM16: - instr_data->immediate = instr_word; - nibl_count += 3; - break; - case ARG_IMM32: - instr_data->immediate = instr_long; - nibl_count += 7; - break; - case ARG_IMMN: - instr_data->immediate = instr_nibl -1; - break; - /* ????? */ - /* missing ARG_IMMNMINUS1 */ - case ARG_IMM_1: - instr_data->immediate = 1; - break; - case ARG_IMM_2: - instr_data->immediate = 2; - break; - case ARG_NIM16: - instr_data->immediate = (- instr_word); - nibl_count += 3; - break; - case ARG_IMM2: - instr_data->immediate = instr_nibl & 0x3; - break; - default: - break; - } - break; - case CLASS_CC: - instr_data->cond_code = instr_nibl; - break; - case CLASS_CTRL: - instr_data->ctrl_code = instr_nibl; - break; - case CLASS_DA: - case CLASS_ADDRESS: - if( is_segmented() ) - { - if( instr_nibl & 0x8 ) - { - instr_data->address = ((instr_word & 0x7f00) << 8) + - (instr_long & 0xffff); - nibl_count += 7; - } - else - { - instr_data->address = ((instr_word & 0x7f00) << 8) + - (instr_word & 0x00ff); - nibl_count += 3; - } - } - else - { - instr_data->address = instr_word; - nibl_count += 3; - } - break; - case CLASS_0CCC: - instr_data->cond_code = instr_nibl & 0x7; - break; - case CLASS_1CCC: - instr_data->cond_code = instr_nibl & 0x7; - break; - case CLASS_0DISP7: - instr_data->displacement = instr_byte & 0x7f; - nibl_count += 1; - break; - case CLASS_1DISP7: - instr_data->displacement = instr_byte & 0x7f; - nibl_count += 1; - break; - case CLASS_01II: - instr_data->interrupts = instr_nibl & 0x3; - break; - case CLASS_00II: - instr_data->interrupts = instr_nibl & 0x3; - break; - case CLASS_BIT: - /* do nothing */ - break; - case CLASS_IR: - instr_data->arg_reg[datum_value] = instr_nibl; - break; - case CLASS_FLAGS: - instr_data->flags = instr_nibl; - break; - case CLASS_REG: - instr_data->arg_reg[datum_value] = instr_nibl; - break; - case CLASS_REG_BYTE: - instr_data->arg_reg[datum_value] = instr_nibl; - break; - case CLASS_REG_WORD: - instr_data->arg_reg[datum_value] = instr_nibl; - break; - case CLASS_REG_QUAD: - instr_data->arg_reg[datum_value] = instr_nibl; - break; - case CLASS_REG_LONG: - instr_data->arg_reg[datum_value] = instr_nibl; - break; - case CLASS_REGN0: - instr_data->arg_reg[datum_value] = instr_nibl; - break; - default: - break; - } + switch (datum_class) + { + case CLASS_X: + instr_data->address = instr_nibl; + break; + case CLASS_BA: + instr_data->displacement = instr_nibl; + break; + case CLASS_BX: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + case CLASS_DISP: + switch (datum_value) + { + case ARG_DISP16: + instr_data->displacement = instr_word; + nibl_count += 3; + break; + case ARG_DISP12: + instr_data->displacement = instr_word & 0x0fff; + nibl_count += 2; + break; + default: + break; + } + break; + case CLASS_IMM: + switch (datum_value) + { + case ARG_IMM4: + instr_data->immediate = instr_nibl; + break; + case ARG_NIM8: + instr_data->immediate = (-instr_byte); + nibl_count += 1; + break; + case ARG_IMM8: + instr_data->immediate = instr_byte; + nibl_count += 1; + break; + case ARG_IMM16: + instr_data->immediate = instr_word; + nibl_count += 3; + break; + case ARG_IMM32: + FETCH_DATA (info, nibl_count + 8); + instr_long = (instr_data->words[nibl_count] << 16) + | (instr_data->words[nibl_count + 4]); + instr_data->immediate = instr_long; + nibl_count += 7; + break; + case ARG_IMMN: + instr_data->immediate = instr_nibl - 1; + break; + /* ????? */ + /* missing ARG_IMMNMINUS1 */ + case ARG_IMM_1: + instr_data->immediate = 1; + break; + case ARG_IMM_2: + instr_data->immediate = 2; + break; + case ARG_IMM2: + instr_data->immediate = instr_nibl & 0x3; + break; + default: + break; + } + break; + case CLASS_CC: + instr_data->cond_code = instr_nibl; + break; + case CLASS_CTRL: + instr_data->ctrl_code = instr_nibl; + break; + case CLASS_DA: + case CLASS_ADDRESS: + if (is_segmented) + { + if (instr_nibl & 0x8) + { + FETCH_DATA (info, nibl_count + 8); + instr_long = (instr_data->words[nibl_count] << 16) + | (instr_data->words[nibl_count + 4]); + instr_data->address = ((instr_word & 0x7f00) << 8) + + (instr_long & 0xffff); + nibl_count += 7; + } + else + { + instr_data->address = ((instr_word & 0x7f00) << 8) + + (instr_word & 0x00ff); + nibl_count += 3; + } + } + else + { + instr_data->address = instr_word; + nibl_count += 3; + } + break; + case CLASS_0CCC: + instr_data->cond_code = instr_nibl & 0x7; + break; + case CLASS_1CCC: + instr_data->cond_code = instr_nibl & 0x7; + break; + case CLASS_0DISP7: + instr_data->displacement = instr_byte & 0x7f; + nibl_count += 1; + break; + case CLASS_1DISP7: + instr_data->displacement = instr_byte & 0x7f; + nibl_count += 1; + break; + case CLASS_01II: + instr_data->interrupts = instr_nibl & 0x3; + break; + case CLASS_00II: + instr_data->interrupts = instr_nibl & 0x3; + break; + case CLASS_BIT: + /* do nothing */ + break; + case CLASS_IR: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + case CLASS_FLAGS: + instr_data->flags = instr_nibl; + break; + case CLASS_REG: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + case CLASS_REG_BYTE: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + case CLASS_REG_WORD: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + case CLASS_REG_QUAD: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + case CLASS_REG_LONG: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + case CLASS_REGN0: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + default: + break; + } loop += 1; nibl_count += 1; - } + } } -static void unparse_instr( instr_data ) -instr_data_s *instr_data; +static void +unparse_instr (instr_data) + instr_data_s *instr_data; { - unsigned short tabl_datum, datum_class, datum_value; - int loop, loop_limit; - char out_str[80], tmp_str[25]; + unsigned short tabl_datum, datum_class, datum_value; + int loop, loop_limit; + char out_str[80], tmp_str[25]; - sprintf( out_str, "\t%s\t", z8k_table[instr_data->tabl_index].name ); + sprintf (out_str, "\t%s\t", z8k_table[instr_data->tabl_index].name); - loop_limit = z8k_table[instr_data->tabl_index].noperands; - for( loop = 0; loop < loop_limit; loop++ ) - { - if( loop ) - strcat( out_str, "," ); + loop_limit = z8k_table[instr_data->tabl_index].noperands; + for (loop = 0; loop < loop_limit; loop++) + { + if (loop) + strcat (out_str, ","); tabl_datum = z8k_table[instr_data->tabl_index].arg_info[loop]; datum_class = tabl_datum & CLASS_MASK; datum_value = tabl_datum & ~CLASS_MASK; - switch( datum_class ) - { - case CLASS_X: - sprintf( tmp_str, "0x%0x(R%d)", instr_data->address, - instr_data->arg_reg[datum_value] ); - strcat( out_str, tmp_str ); - break; - case CLASS_BA: - sprintf( tmp_str, "r%d(#%x)", instr_data->arg_reg[datum_value], - instr_data->displacement); - strcat( out_str, tmp_str ); - break; - case CLASS_BX: - sprintf( tmp_str, "r%d(R%d)", instr_data->arg_reg[datum_value], - instr_data->arg_reg[ARG_RX] ); - strcat( out_str, tmp_str ); - break; - case CLASS_DISP: - sprintf( tmp_str, "#0x%0x", instr_data->displacement ); - strcat( out_str, tmp_str ); - break; - case CLASS_IMM: - sprintf( tmp_str, "#0x%0x", instr_data->immediate ); - strcat( out_str, tmp_str ); - break; - case CLASS_CC: - sprintf( tmp_str, "%s", codes[instr_data->cond_code] ); - strcat( out_str, tmp_str ); - break; - case CLASS_CTRL: - sprintf( tmp_str, "0x%0x", instr_data->ctrl_code ); - strcat( out_str, tmp_str ); - break; - case CLASS_DA: - case CLASS_ADDRESS: - sprintf( tmp_str, "#0x%0x", instr_data->address ); - strcat( out_str, tmp_str ); - break; - case CLASS_IR: - sprintf( tmp_str, "@R%d", instr_data->arg_reg[datum_value] ); - strcat( out_str, tmp_str ); - break; - case CLASS_FLAGS: - sprintf( tmp_str, "0x%0x", instr_data->flags ); - strcat( out_str, tmp_str ); - break; - case CLASS_REG_BYTE: - if( instr_data->arg_reg[datum_value] >= 0x8 ) - { - sprintf( tmp_str, "rl%d", - instr_data->arg_reg[datum_value] - 0x8 ); - } - else - { - sprintf( tmp_str, "rh%d", instr_data->arg_reg[datum_value] ); - } - strcat( out_str, tmp_str ); - break; - case CLASS_REG_WORD: - sprintf( tmp_str, "r%d", instr_data->arg_reg[datum_value] ); - strcat( out_str, tmp_str ); - break; - case CLASS_REG_QUAD: - sprintf( tmp_str, "rq%d", instr_data->arg_reg[datum_value] ); - strcat( out_str, tmp_str ); - break; - case CLASS_REG_LONG: - sprintf( tmp_str, "rr%d", instr_data->arg_reg[datum_value] ); - strcat( out_str, tmp_str ); - break; - default: - break; - } - } + switch (datum_class) + { + case CLASS_X: + sprintf (tmp_str, "0x%0x(R%d)", instr_data->address, + instr_data->arg_reg[datum_value]); + strcat (out_str, tmp_str); + break; + case CLASS_BA: + sprintf (tmp_str, "r%d(#%x)", instr_data->arg_reg[datum_value], + instr_data->immediate); + strcat (out_str, tmp_str); + break; + case CLASS_BX: + sprintf (tmp_str, "r%d(R%d)", instr_data->arg_reg[datum_value], + instr_data->arg_reg[ARG_RX]); + strcat (out_str, tmp_str); + break; + case CLASS_DISP: + sprintf (tmp_str, "#0x%0x", instr_data->displacement); + strcat (out_str, tmp_str); + break; + case CLASS_IMM: + sprintf (tmp_str, "#0x%0x", instr_data->immediate); + strcat (out_str, tmp_str); + break; + case CLASS_CC: + sprintf (tmp_str, "%s", codes[instr_data->cond_code]); + strcat (out_str, tmp_str); + break; + case CLASS_CTRL: + sprintf (tmp_str, "0x%0x", instr_data->ctrl_code); + strcat (out_str, tmp_str); + break; + case CLASS_DA: + case CLASS_ADDRESS: + sprintf (tmp_str, "#0x%0x", instr_data->address); + strcat (out_str, tmp_str); + break; + case CLASS_IR: + sprintf (tmp_str, "@R%d", instr_data->arg_reg[datum_value]); + strcat (out_str, tmp_str); + break; + case CLASS_FLAGS: + sprintf (tmp_str, "0x%0x", instr_data->flags); + strcat (out_str, tmp_str); + break; + case CLASS_REG_BYTE: + if (instr_data->arg_reg[datum_value] >= 0x8) + { + sprintf (tmp_str, "rl%d", + instr_data->arg_reg[datum_value] - 0x8); + } + else + { + sprintf (tmp_str, "rh%d", instr_data->arg_reg[datum_value]); + } + strcat (out_str, tmp_str); + break; + case CLASS_REG_WORD: + sprintf (tmp_str, "r%d", instr_data->arg_reg[datum_value]); + strcat (out_str, tmp_str); + break; + case CLASS_REG_QUAD: + sprintf (tmp_str, "rq%d", instr_data->arg_reg[datum_value]); + strcat (out_str, tmp_str); + break; + case CLASS_REG_LONG: + sprintf (tmp_str, "rr%d", instr_data->arg_reg[datum_value]); + strcat (out_str, tmp_str); + break; + default: + break; + } + } - strcpy( instr_data->instr_asmsrc, out_str ); + strcpy (instr_data->instr_asmsrc, out_str); } |