/* Print DEC PDP-11 instructions.
- Copyright 2001, 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2001-2020 Free Software Foundation, Inc.
This file is part of the GNU opcodes library.
MA 02110-1301, USA. */
#include "sysdep.h"
-#include "dis-asm.h"
+#include "disassemble.h"
#include "opcode/pdp11.h"
#define AFTER_INSTRUCTION "\t"
#define F info->stream
/* Sign-extend a 16-bit number in an int. */
-#define SIGN_BITS (8 * sizeof (int) - 16)
-#define sign_extend(x) (((x) << SIGN_BITS) >> SIGN_BITS)
+#define sign_extend(x) ((((x) & 0xffff) ^ 0x8000) - 0x8000)
static int
read_word (bfd_vma memaddr, int *word, disassemble_info *info)
switch (OP.type)
{
case PDP11_OPCODE_NO_OPS:
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
goto done;
case PDP11_OPCODE_REG:
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
print_reg (dst, info);
goto done;
case PDP11_OPCODE_OP:
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
if (strcmp (OP.name, "jmp") == 0)
dst |= JUMP;
return -1;
goto done;
case PDP11_OPCODE_FOP:
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
if (strcmp (OP.name, "jmp") == 0)
dst |= JUMP;
return -1;
goto done;
case PDP11_OPCODE_REG_OP:
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
print_reg (src, info);
FPRINTF (F, OPERAND_SEPARATOR);
return -1;
goto done;
case PDP11_OPCODE_REG_OP_REV:
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
if (print_operand (&memaddr, dst, info) < 0)
return -1;
case PDP11_OPCODE_AC_FOP:
{
int ac = (opcode & 0xe0) >> 6;
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
print_freg (ac, info);
FPRINTF (F, OPERAND_SEPARATOR);
case PDP11_OPCODE_FOP_AC:
{
int ac = (opcode & 0xe0) >> 6;
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
if (print_foperand (&memaddr, dst, info) < 0)
return -1;
case PDP11_OPCODE_AC_OP:
{
int ac = (opcode & 0xe0) >> 6;
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
print_freg (ac, info);
FPRINTF (F, OPERAND_SEPARATOR);
case PDP11_OPCODE_OP_AC:
{
int ac = (opcode & 0xe0) >> 6;
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
if (print_operand (&memaddr, dst, info) < 0)
return -1;
goto done;
}
case PDP11_OPCODE_OP_OP:
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
if (print_operand (&memaddr, src, info) < 0)
return -1;
{
int displ = (opcode & 0xff) << 8;
bfd_vma address = memaddr + (sign_extend (displ) >> 7);
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
(*info->print_address_func) (address, info);
goto done;
int displ = (opcode & 0x3f) << 10;
bfd_vma address = memaddr - (displ >> 9);
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
print_reg (src, info);
FPRINTF (F, OPERAND_SEPARATOR);
case PDP11_OPCODE_IMM8:
{
int code = opcode & 0xff;
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
FPRINTF (F, "%o", code);
goto done;
case PDP11_OPCODE_IMM6:
{
int code = opcode & 0x3f;
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
FPRINTF (F, "%o", code);
goto done;
case PDP11_OPCODE_IMM3:
{
int code = opcode & 7;
- FPRINTF (F, OP.name);
+ FPRINTF (F, "%s", OP.name);
FPRINTF (F, AFTER_INSTRUCTION);
FPRINTF (F, "%o", code);
goto done;