This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
[patch] avr port: bug in disassembler
- To: binutils at sourceware dot cygnus dot com
- Subject: [patch] avr port: bug in disassembler
- From: Denis Chertykov <denisc at overta dot ru>
- Date: Sun, 2 Apr 2000 18:53:46 +0400
Sun Apr 2 18:44:20 2000 Denis Chertykov <denisc@overta.ru>
* avr-dis.c: Syntax cleanup
(add0fff): Use the pc relative address as a signed number.
(add03f8): Likewise.
Index: binutils/opcodes/avr-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/avr-dis.c,v
retrieving revision 1.1
diff -u -5 -r1.1 avr-dis.c
--- avr-dis.c 2000/03/27 08:39:14 1.1
+++ avr-dis.c 2000/04/02 14:47:26
@@ -24,11 +24,10 @@
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
#define IFMASK(a,b) ((opcode & (a)) == (b))
-#define CODE_MAX 65537
static char* SREG_flags = "CZNVSHTI";
static char* sect94[] = {"COM","NEG","SWAP","INC","NULL","ASR","LSR","ROR",
0,0,"DEC",0,0,0,0,0};
static char* sect98[] = {"CBI","SBIC","SBI","SBIS"};
@@ -36,12 +35,12 @@
"BRCS","BREQ","BRMI","BRVS",
"BRLT","BRHS","BRTS","BRIE",
"BRCC","BRNE","BRPL","BRVC",
"BRGE","BRHC","BRTC","BRID"
};
-static char* last4[] = {"BLD","BST","SBRC","SBRS"};
+static char* last4[] = {"BLD","BST","SBRC","SBRS"};
static void dispLDD PARAMS ((u16, char *));
static void
@@ -145,12 +144,14 @@
add0fff (op, dest, pc)
u16 op;
char *dest;
int pc;
{
- int opcode = op & 0x0fff;
- sprintf(dest, ".%+-8d ; 0x%06X", opcode * 2, pc + 2 + opcode * 2);
+ int rel_addr = (op & (1 << 11)
+ ? (-1 ^ 0xfff) | (op & 0xfff)
+ : op & 0xfff) * 2;
+ sprintf(dest, ".%+-8d ; 0x%06X", rel_addr, pc + 2 + rel_addr);
}
static void add03f8 PARAMS ((u16, char *, int));
@@ -158,12 +159,14 @@
add03f8 (op, dest, pc)
u16 op;
char *dest;
int pc;
{
- int opcode = (op >> 3) & 0x7f;
- sprintf(dest, ".%+-8d ; 0x%06X", opcode * 2, pc + 2 + opcode * 2);
+ int rel_addr;
+ op >>= 3;
+ rel_addr = (op & (1 << 6) ? (-1 ^ 0x7f) | (op & 0x7f) : op & 0x7f) * 2;
+ sprintf(dest, ".%+-8d ; 0x%06X", rel_addr, pc + 2 + rel_addr);
}
static u16 avrdis_opcode PARAMS ((bfd_vma, disassemble_info *));
@@ -329,53 +332,35 @@
avrdis_opcode(addr + 2, info));
cmd_len = 4;
}
break;
case 0x1:
- {
- (*prin) (stream, " LD %s,Z+", rd);
- }
+ (*prin) (stream, " LD %s,Z+", rd);
break;
case 0x2:
- {
- (*prin) (stream, " LD %s,-Z", rd);
- }
+ (*prin) (stream, " LD %s,-Z", rd);
break;
case 0x9:
- {
- (*prin) (stream, " LD %s,Y+", rd);
- }
+ (*prin) (stream, " LD %s,Y+", rd);
break;
case 0xa:
- {
- (*prin) (stream, " LD %s,-Y", rd);
- }
+ (*prin) (stream, " LD %s,-Y", rd);
break;
case 0xc:
- {
- (*prin) (stream, " LD %s,X", rd);
- }
+ (*prin) (stream, " LD %s,X", rd);
break;
case 0xd:
- {
- (*prin) (stream, " LD %s,X+", rd);
- }
+ (*prin) (stream, " LD %s,X+", rd);
break;
case 0xe:
- {
- (*prin) (stream, " LD %s,-X", rd);
- }
+ (*prin) (stream, " LD %s,-X", rd);
break;
case 0xf:
- {
- (*prin) (stream, " POP %s", rd);
- }
+ (*prin) (stream, " POP %s", rd);
break;
default:
- {
- (*prin) (stream, " ????");
- }
+ (*prin) (stream, " ????");
break;
}
}
break;
case 0x0200:
@@ -389,53 +374,35 @@
avrdis_opcode(addr + 2, info), rd);
cmd_len = 4;
}
break;
case 0x1:
- {
- (*prin) (stream, " ST Z+,%s", rd);
- }
+ (*prin) (stream, " ST Z+,%s", rd);
break;
case 0x2:
- {
- (*prin) (stream, " ST -Z,%s", rd);
- }
+ (*prin) (stream, " ST -Z,%s", rd);
break;
case 0x9:
- {
- (*prin) (stream, " ST Y+,%s", rd);
- }
+ (*prin) (stream, " ST Y+,%s", rd);
break;
case 0xa:
- {
- (*prin) (stream, " ST -Y,%s", rd);
- }
+ (*prin) (stream, " ST -Y,%s", rd);
break;
case 0xc:
- {
- (*prin) (stream, " ST X,%s", rd);
- }
+ (*prin) (stream, " ST X,%s", rd);
break;
case 0xd:
- {
- (*prin) (stream, " ST X+,%s", rd);
- }
+ (*prin) (stream, " ST X+,%s", rd);
break;
case 0xe:
- {
- (*prin) (stream, " ST -X,%s", rd);
- }
+ (*prin) (stream, " ST -X,%s", rd);
break;
case 0xf:
- {
- (*prin) (stream, " PUSH %s", rd);
- }
+ (*prin) (stream, " PUSH %s", rd);
break;
default:
- {
- (*prin) (stream, " ????");
- }
+ (*prin) (stream, " ????");
break;
}
}
break;
case 0x0400: