diff --git a/py65/monitor.py b/py65/monitor.py index 5070317..88c8972 100644 --- a/py65/monitor.py +++ b/py65/monitor.py @@ -442,16 +442,21 @@ class Monitor(cmd.Cmd): self._output("Display a number in decimal, hex, octal, and binary.") def do_tilde(self, args): + if args == '': + return self.help_tilde() + try: num = self._address_parser.number(args) - except ValueError: - self._output("Syntax error: %s" % args) - return - - self._output("+%u" % num) - self._output("$" + self.byteFmt % num) - self._output("%04o" % num) - self._output(itoa(num, 2).zfill(8)) + self._output("+%u" % num) + self._output("$" + self.byteFmt % num) + self._output("%04o" % num) + self._output(itoa(num, 2).zfill(8)) + except KeyError: + self._output("Bad label: %s" % args) + except OverflowError: + self._output("Overflow error: %s" % args) + except SyntaxError: + self._output("Syntax error: %s" % statement) def help_registers(self): self._output("registers[= [, =]*]") diff --git a/py65/tests/test_monitor.py b/py65/tests/test_monitor.py index 1eae781..afbaad6 100644 --- a/py65/tests/test_monitor.py +++ b/py65/tests/test_monitor.py @@ -804,6 +804,14 @@ class MonitorTests(unittest.TestCase): expected = "+16\n$10\n0020\n00010000\n" self.assertTrue(out.startswith(expected)) + def test_do_tilde_with_no_arg_shows_help(self): + stdout = StringIO() + mon = Monitor(stdout=stdout) + mon.do_tilde('') + out = stdout.getvalue() + expected = "~ " + self.assertTrue(out.startswith(expected)) + def test_help_tilde(self): stdout = StringIO() mon = Monitor(stdout=stdout)