From 318b62431d335f84916ab47617731e5c48e426c2 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Mon, 19 Apr 2021 11:21:47 +0200 Subject: [PATCH] catching invalid immediate value now --- riscemu/helpers.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/riscemu/helpers.py b/riscemu/helpers.py index 1e37b98..235d53c 100644 --- a/riscemu/helpers.py +++ b/riscemu/helpers.py @@ -1,7 +1,7 @@ from math import log10, ceil, log from .Exceptions import NumberFormatException from .colors import * - +from .Exceptions import * def align_addr(addr: int, to_bytes: int = 8): """ @@ -14,10 +14,12 @@ def parse_numeric_argument(arg: str): """ parse hex or int strings """ - if '0x' in arg or '0X' in arg: - return int(arg, 16) - return int(arg) - + try: + if '0x' in arg or '0X' in arg: + return int(arg, 16) + return int(arg) + except ValueError as ex: + raise ParseException('Invalid immediate argument \"{}\", maybe missing symbol?'.format(arg), (arg, ex)) def int_to_bytes(val, bytes=4, unsigned=False): """