/* Print Z80 and R800 instructions
- Copyright 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005-2015 Free Software Foundation, Inc.
Contributed by Arnold Metselaar <arnold_m@operamail.com>
- This file is free software; you can redistribute it and/or modify
+ This file is part of the GNU opcodes library.
+
+ This library 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.
+ the Free Software Foundation; either version 3, 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.
+ It 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
bfd_vma base;
int n_fetch;
int n_used;
- unsigned char data[4];
+ signed char data[4];
} ;
typedef int (*func)(struct buffer *, disassemble_info *, char *);
char * text;
} ;
-#define TXTSIZ 16
+#define TXTSIZ 24
/* Names of 16-bit registers. */
static char * rr_str[] = { "bc", "de", "hl", "sp" };
/* Names of 8-bit registers. */
abort ();
r = info->read_memory_func (buf->base + buf->n_fetch,
- buf->data + buf->n_fetch,
+ (unsigned char*) buf->data + buf->n_fetch,
n, info);
if (r == 0)
buf->n_fetch += n;
prt_rr_nn (struct buffer *buf, disassemble_info * info, char *txt)
{
char mytxt[TXTSIZ];
+ int rr;
- snprintf (mytxt, TXTSIZ, txt, rr_str[(buf->data[0] >> 4) & 3]);
+ rr = (buf->data[buf->n_fetch - 1] >> 4) & 3;
+ snprintf (mytxt, TXTSIZ, txt, rr_str[rr]);
return prt_nn (buf, info, mytxt);
}
{ 0x4A, 0xCF, prt_rr, "adc hl," },
{ 0x4B, 0xCF, prt_rr_nn, "ld %s,(0x%%04x)" },
{ 0x4D, 0xFF, prt, "reti" },
+ { 0x4F, 0xFF, prt, "ld r,a" },
{ 0x56, 0xFF, prt, "im 1" },
{ 0x57, 0xFF, prt, "ld a,i" },
{ 0x5E, 0xFF, prt, "im 2" },
+ { 0x5F, 0xFF, prt, "ld a,r" },
{ 0x67, 0xFF, prt, "rrd" },
{ 0x6F, 0xFF, prt, "rld" },
{ 0xA0, 0xE4, cis, "" },
prt_d (struct buffer *buf, disassemble_info * info, char *txt)
{
int d;
- unsigned char *p;
+ signed char *p;
p = buf->data + buf->n_fetch;
{
char mytxt[TXTSIZ];
int d;
- unsigned char *p;
+ signed char *p;
p = buf->data + buf->n_fetch;
arit_d (struct buffer *buf, disassemble_info * info, char *txt)
{
char mytxt[TXTSIZ];
- unsigned char c;
+ signed char c;
c = buf->data[buf->n_fetch - 1];
snprintf (mytxt, TXTSIZ, txt, arit_str[(c >> 3) & 7]);
ld_r_d (struct buffer *buf, disassemble_info * info, char *txt)
{
char mytxt[TXTSIZ];
- unsigned char c;
+ signed char c;
c = buf->data[buf->n_fetch - 1];
snprintf (mytxt, TXTSIZ, txt, r_str[(c >> 3) & 7]);
ld_d_r(struct buffer *buf, disassemble_info * info, char *txt)
{
char mytxt[TXTSIZ];
- unsigned char c;
+ signed char c;
c = buf->data[buf->n_fetch - 1];
snprintf (mytxt, TXTSIZ, txt, r_str[c & 7]);
{
int d;
char arg[TXTSIZ];
- unsigned char *p;
+ signed char *p;
buf->n_used = 4;
p = buf->data;
d = p[2];
if (((p[3] & 0xC0) == 0x40) || ((p[3] & 7) == 0x06))
- snprintf (arg, TXTSIZ, "(%s+%d)", txt, d);
+ snprintf (arg, TXTSIZ, "(%s%+d)", txt, d);
else
- snprintf (arg, TXTSIZ, "(%s+%d),%s", txt, d, r_str[p[3] & 7]);
+ snprintf (arg, TXTSIZ, "(%s%+d),%s", txt, d, r_str[p[3] & 7]);
if ((p[3] & 0xc0) == 0)
info->fprintf_func (info->stream, "%s %s",
{ 0x2B, 0xFF, prt, "dec %s" },
{ 0x29, 0xFF, addvv, "%s" },
{ 0x09, 0xCF, prt_rr, "add %s," },
- { 0x34, 0xFF, prt_d, "inc (%s+%%d)" },
- { 0x35, 0xFF, prt_d, "dec (%s+%%d)" },
- { 0x36, 0xFF, prt_d_n, "ld (%s+%%d),0x%%02x" },
+ { 0x34, 0xFF, prt_d, "inc (%s%%+d)" },
+ { 0x35, 0xFF, prt_d, "dec (%s%%+d)" },
+ { 0x36, 0xFF, prt_d_n, "ld (%s%%+d),0x%%%%02x" },
{ 0x76, 0xFF, dump, "h" },
- { 0x46, 0xC7, ld_r_d, "ld %%s,(%s+%%%%d)" },
- { 0x70, 0xF8, ld_d_r, "ld (%s+%%%%d),%%s" },
+ { 0x46, 0xC7, ld_r_d, "ld %%s,(%s%%%%+d)" },
+ { 0x70, 0xF8, ld_d_r, "ld (%s%%%%+d),%%s" },
{ 0x64, 0xF6, ld_v_v, "%s" },
{ 0x60, 0xF0, ld_r_r, "ld %s%%s,%%s" },
{ 0x44, 0xC6, ld_r_r, "ld %%s,%s%%s" },
- { 0x86, 0xC7, arit_d, "%%s(%s+%%%%d)" },
+ { 0x86, 0xC7, arit_d, "%%s(%s%%%%+d)" },
{ 0x84, 0xC6, arit_r, "%%s%s%%s" },
{ 0xE1, 0xFF, prt, "pop %s" },