diff options
author | Nick Clifton <nickc@redhat.com> | 2001-04-24 15:22:25 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2001-04-24 15:22:25 +0000 |
commit | 6840198f93340023b478d4df838efb37b9b27998 (patch) | |
tree | f456409a1dcc4b56504c63543d007a08d8649371 /opcodes/z8k-dis.c | |
parent | b3baf5d0a8293b5f823c0d7848494507edb373fb (diff) | |
download | gdb-6840198f93340023b478d4df838efb37b9b27998.zip gdb-6840198f93340023b478d4df838efb37b9b27998.tar.gz gdb-6840198f93340023b478d4df838efb37b9b27998.tar.bz2 |
z8k fixes
Diffstat (limited to 'opcodes/z8k-dis.c')
-rw-r--r-- | opcodes/z8k-dis.c | 79 |
1 files changed, 59 insertions, 20 deletions
diff --git a/opcodes/z8k-dis.c b/opcodes/z8k-dis.c index 8259500..77c2495 100644 --- a/opcodes/z8k-dis.c +++ b/opcodes/z8k-dis.c @@ -125,11 +125,24 @@ static char *codes[16] = "nc/uge" }; +static char *ctrl_names[8] = +{ + "<invld>", + "flags", + "fcw", + "refresh", + "psapseg", + "psapoff", + "nspseg", + "nspoff" +}; + +static int seg_length; 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 void unparse_instr PARAMS ((instr_data_s *,int)); static int print_insn_z8k (addr, info, is_segmented) @@ -150,9 +163,9 @@ print_insn_z8k (addr, info, is_segmented) if (instr_data.tabl_index > 0) { unpack_instr (&instr_data, is_segmented, info); - unparse_instr (&instr_data); + unparse_instr (&instr_data, is_segmented); output_instr (&instr_data, addr, info); - return z8k_table[instr_data.tabl_index].length; + return z8k_table[instr_data.tabl_index].length + seg_length; } else { @@ -275,7 +288,7 @@ output_instr (instr_data, addr, info) strcpy (out_str, "\t"); - loop_limit = z8k_table[instr_data->tabl_index].length * 2; + loop_limit = (z8k_table[instr_data->tabl_index].length + seg_length) * 2; FETCH_DATA (info, loop_limit); for (loop = 0; loop < loop_limit; loop++) { @@ -302,16 +315,18 @@ unpack_instr (instr_data, is_segmented, info) int nibl_count, loop; unsigned short instr_nibl, instr_byte, instr_word; long instr_long; - unsigned short tabl_datum, datum_class, datum_value; + unsigned int tabl_datum, datum_class; + unsigned short datum_value; nibl_count = 0; loop = 0; + seg_length = 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]; + instr_byte = instr_data->bytes[nibl_count&~1]; + instr_word = instr_data->words[nibl_count&~3]; tabl_datum = z8k_table[instr_data->tabl_index].byte_info[loop]; datum_class = tabl_datum & CLASS_MASK; @@ -332,11 +347,18 @@ unpack_instr (instr_data, is_segmented, info) switch (datum_value) { case ARG_DISP16: - instr_data->displacement = instr_word; + instr_data->displacement = instr_data->insn_start + 4 + + (signed short)(instr_word & 0xffff); nibl_count += 3; break; case ARG_DISP12: - instr_data->displacement = instr_word & 0x0fff; + if (instr_word & 0x800) { /* neg. 12 bit displacement */ + instr_data->displacement = instr_data->insn_start + 2 - + (signed short)((instr_word & 0xfff) | 0xf000) * 2; + } + else { + instr_data->displacement = instr_data->insn_start + 2 - (instr_word & 0x0fff) * 2; + } nibl_count += 2; break; default: @@ -390,9 +412,11 @@ unpack_instr (instr_data, is_segmented, info) case CLASS_CC: instr_data->cond_code = instr_nibl; break; +#if 0 case CLASS_CTRL: instr_data->ctrl_code = instr_nibl; break; +#endif case CLASS_DA: case CLASS_ADDRESS: if (is_segmented) @@ -405,6 +429,7 @@ unpack_instr (instr_data, is_segmented, info) instr_data->address = ((instr_word & 0x7f00) << 8) + (instr_long & 0xffff); nibl_count += 7; + seg_length = 2; } else { @@ -420,17 +445,15 @@ unpack_instr (instr_data, is_segmented, info) } break; case CLASS_0CCC: - instr_data->cond_code = instr_nibl & 0x7; - break; case CLASS_1CCC: - instr_data->cond_code = instr_nibl & 0x7; + instr_data->ctrl_code = instr_nibl & 0x7; break; case CLASS_0DISP7: - instr_data->displacement = instr_byte & 0x7f; + instr_data->displacement = instr_data->insn_start + 2 - (instr_byte & 0x7f) * 2; nibl_count += 1; break; case CLASS_1DISP7: - instr_data->displacement = instr_byte & 0x7f; + instr_data->displacement = instr_data->insn_start + 2 - (instr_byte & 0x7f) * 2; nibl_count += 1; break; case CLASS_01II: @@ -440,7 +463,7 @@ unpack_instr (instr_data, is_segmented, info) instr_data->interrupts = instr_nibl & 0x3; break; case CLASS_BIT: - /* Do nothing. */ + instr_data->ctrl_code = instr_nibl & 0x7; break; case CLASS_IR: instr_data->arg_reg[datum_value] = instr_nibl; @@ -466,6 +489,13 @@ unpack_instr (instr_data, is_segmented, info) case CLASS_REGN0: instr_data->arg_reg[datum_value] = instr_nibl; break; + case CLASS_PR: + instr_data->arg_reg[datum_value] = instr_nibl; + break; + case CLASS_DISP8: + instr_data->displacement = instr_data->insn_start + 2 + (signed char)instr_byte * 2; + nibl_count += 1; + break; default: break; } @@ -476,10 +506,12 @@ unpack_instr (instr_data, is_segmented, info) } static void -unparse_instr (instr_data) +unparse_instr (instr_data,is_segmented) instr_data_s *instr_data; + int is_segmented; { - unsigned short tabl_datum, datum_class, datum_value; + unsigned short datum_value; + unsigned int tabl_datum, datum_class; int loop, loop_limit; char out_str[80], tmp_str[25]; @@ -513,7 +545,7 @@ unparse_instr (instr_data) strcat (out_str, tmp_str); break; case CLASS_DISP: - sprintf (tmp_str, "#0x%0lx", instr_data->displacement); + sprintf (tmp_str, "0x%0lx", instr_data->displacement); strcat (out_str, tmp_str); break; case CLASS_IMM: @@ -525,12 +557,12 @@ unparse_instr (instr_data) strcat (out_str, tmp_str); break; case CLASS_CTRL: - sprintf (tmp_str, "0x%0lx", instr_data->ctrl_code); + sprintf (tmp_str, "%s", ctrl_names[instr_data->ctrl_code]); strcat (out_str, tmp_str); break; case CLASS_DA: case CLASS_ADDRESS: - sprintf (tmp_str, "#0x%0lx", instr_data->address); + sprintf (tmp_str, "0x%0lx", instr_data->address); strcat (out_str, tmp_str); break; case CLASS_IR: @@ -565,6 +597,13 @@ unparse_instr (instr_data) sprintf (tmp_str, "rr%ld", instr_data->arg_reg[datum_value]); strcat (out_str, tmp_str); break; + case CLASS_PR: + if (is_segmented) + sprintf (tmp_str, "rr%ld", instr_data->arg_reg[datum_value]); + else + sprintf (tmp_str, "r%ld", instr_data->arg_reg[datum_value]); + strcat (out_str, tmp_str); + break; default: break; } |