+/* Subroutine of disassemble_command to simplify it.
+ Perform the disassembly.
+ NAME is the name of the function if known, or NULL.
+ [LOW,HIGH) are the range of addresses to disassemble.
+ MIXED is non-zero to print source with the assembler. */
+
+static void
+print_disassembly (struct gdbarch *gdbarch, const char *name,
+ CORE_ADDR low, CORE_ADDR high, int flags)
+{
+#if defined(TUI)
+ if (!tui_is_window_visible (DISASSEM_WIN))
+#endif
+ {
+ printf_filtered ("Dump of assembler code ");
+ if (name != NULL)
+ printf_filtered ("for function %s:\n", name);
+ else
+ printf_filtered ("from %s to %s:\n",
+ paddress (gdbarch, low), paddress (gdbarch, high));
+
+ /* Dump the specified range. */
+ gdb_disassembly (gdbarch, uiout, 0, flags, -1, low, high);
+
+ printf_filtered ("End of assembler dump.\n");
+ gdb_flush (gdb_stdout);
+ }
+#if defined(TUI)
+ else
+ {
+ tui_show_assembly (gdbarch, low);
+ }
+#endif
+}
+
+/* Subroutine of disassemble_command to simplify it.
+ Print a disassembly of the current function according to FLAGS. */
+
+static void
+disassemble_current_function (int flags)
+{
+ struct frame_info *frame;
+ struct gdbarch *gdbarch;
+ CORE_ADDR low, high, pc;
+ char *name;
+
+ frame = get_selected_frame (_("No frame selected."));
+ gdbarch = get_frame_arch (frame);
+ pc = get_frame_pc (frame);
+ if (find_pc_partial_function (pc, &name, &low, &high) == 0)
+ error (_("No function contains program counter for selected frame."));
+#if defined(TUI)
+ /* NOTE: cagney/2003-02-13 The `tui_active' was previously
+ `tui_version'. */
+ if (tui_active)
+ /* FIXME: cagney/2004-02-07: This should be an observer. */
+ low = tui_get_low_disassembly_address (gdbarch, low, pc);
+#endif
+ low += gdbarch_deprecated_function_start_offset (gdbarch);
+
+ print_disassembly (gdbarch, name, low, high, flags);
+}
+
+/* Dump a specified section of assembly code.
+
+ Usage:
+ disassemble [/mr]
+ - dump the assembly code for the function of the current pc
+ disassemble [/mr] addr
+ - dump the assembly code for the function at ADDR
+ disassemble [/mr] low high
+ - dump the assembly code in the range [LOW,HIGH)
+
+ A /m modifier will include source code with the assembly.
+ A /r modifier will include raw instructions in hex with the assembly. */