Skip to content

Commit 99b95c1

Browse files
committed
Fix general registers token
1 parent 5a13a99 commit 99b95c1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

planner/asm/line_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ def parse_line(line: str) -> Tuple[Optional[str], Optional[List[Tuple[unit.Opera
4747
if op.upper() == memory.TOKEN_ESP:
4848
optype = address_of(optype)
4949
op = str(memory.ESP)
50-
elif op.startswith("R"):
50+
elif op in memory.TOKEN_GENERAL_REGISTERS:
5151
optype = address_of(optype)
5252
try:
5353
rindex = int(op[1:])
5454
except ValueError as e:
55-
raise ValueError(f"Invalid mem-register {op} provided, only R0..R{memory.GENERAL_REGISTERS_COUNT} supported: {e}")
55+
raise ValueError(f"Invalid mem-register {op} provided, only R0..R{memory.GENERAL_REGISTERS_COUNT-1} supported: {e}")
5656
op = str(memory.get_register_address(rindex))
5757
try:
5858
int_val = int(op, 0)

planner/memory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# General Register R0,..R15
44
GENERAL_REGISTERS_COUNT = 8
5+
TOKEN_GENERAL_REGISTERS = [f"R{i}" for i in range(0, GENERAL_REGISTERS_COUNT)]
56
def get_register_address(index):
67
assert index >=0 and index < GENERAL_REGISTERS_COUNT
78
return index*4

0 commit comments

Comments
 (0)