diff options
author | Alan Modra <amodra@bigpond.net.au> | 2000-04-03 14:17:43 +0000 |
---|---|---|
committer | Alan Modra <amodra@bigpond.net.au> | 2000-04-03 14:17:43 +0000 |
commit | d811a9d685f34d9025062c1dc77db5a17a2e6f13 (patch) | |
tree | 49cdc466498edfa72374f6fef96c4c00200981b8 /opcodes | |
parent | 20a45a1be9fd0110342cf5a9dddc212dd97ffc57 (diff) | |
download | binutils-redhat-d811a9d685f34d9025062c1dc77db5a17a2e6f13.tar.gz |
Tidy some code. Print pc rel addresses as signed.
Diffstat (limited to 'opcodes')
-rw-r--r-- | opcodes/ChangeLog | 6 | ||||
-rw-r--r-- | opcodes/avr-dis.c | 83 |
2 files changed, 29 insertions, 60 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index c6d1fea64c..8df6679572 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,9 @@ +2000-04-03 Denis Chertykov <denisc@overta.ru> + + * avr-dis.c: Syntax cleanup. + (add0fff): Print the pc relative address as a signed number. + (add03f8): Likewise. + 2000-04-01 Ian Lance Taylor <ian@zembu.com> * disassemble.c (disassembler_usage): Don't use a prototype. Mark diff --git a/opcodes/avr-dis.c b/opcodes/avr-dis.c index 2d7eb947df..78766869ff 100644 --- a/opcodes/avr-dis.c +++ b/opcodes/avr-dis.c @@ -26,7 +26,6 @@ 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", @@ -38,8 +37,8 @@ static char* branchs[] = { "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 *)); @@ -147,8 +146,8 @@ add0fff (op, dest, pc) char *dest; int pc; { - int opcode = op & 0x0fff; - sprintf(dest, ".%+-8d ; 0x%06X", opcode * 2, pc + 2 + opcode * 2); + int rel_addr = (((op & 0xfff) ^ 0x800) - 0x800) * 2; + sprintf(dest, ".%+-8d ; 0x%06X", rel_addr, pc + 2 + rel_addr); } @@ -160,8 +159,8 @@ add03f8 (op, dest, pc) 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) & 0x7f) ^ 0x40) - 0x40) * 2; + sprintf(dest, ".%+-8d ; 0x%06X", rel_addr, pc + 2 + rel_addr); } @@ -331,49 +330,31 @@ print_insn_avr(addr, info) } 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; } } @@ -391,49 +372,31 @@ print_insn_avr(addr, info) } 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; } } |