Closed stefandrissen closed 3 years ago
Coibcidentally I encountered something v similar (totally human error, same exception raised). In my case I was trying to assemble the following (note again rogue comma)
djnz, -loop
On Sun, 29 Aug 2021, 17:06 Stefan Drissen, @.***> wrote:
While changing some code I accidentally ended up with dec,(iy+something)
note the additional rogue comma. Instead of throwing an error about an invalid instruction, I was given:
[exec] pass 1 ... [exec] Traceback (most recent call last): [exec] File "C:\Users\stefan\git\pyz80\pyz80.py", line 1969, in
[exec] assembler_pass(p, inputfile) [exec] File "C:\Users\stefan\git\pyz80\pyz80.py", line 1776, in assembler_pass [exec] origin = (origin + bytes) % 65536 [exec] TypeError: unsupported operand type(s) for +: 'int' and 'tuple' A simple dec,(hl) is sufficient to trigger this.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/simonowen/pyz80/issues/20, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF47HEONJGFLFVCLGKWTTTT7JLITANCNFSM5DAMCTCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
From the error I suspect it's a side-effect of pyz80 evaluating expressions in native Python. The comma will be seen as a separator for a tuple/list, which rightly gets rejected in arithmetic expressions.
I'll double-check that later, but would imagine a try
block in the right place should be enough to catch this (and similar) evaluation failures.
The worst part was that there is nothing to indicate which source code line is causing the error. I literally had to go through my source adding statements that did not compile to find the offender.
Hopefully the latest code fixes both of your issues!
While changing some code I accidentally ended up with
dec,(iy+something)
- note the additional rogue comma. Instead of throwing an error about an invalid instruction, I was given:A simple
dec,(hl)
is sufficient to trigger this.