endlos99 / xdt99

xdt99: TMS 99xx Cross-Development Tools
http://endlos99.github.io/xdt99
GNU General Public License v3.0
52 stars 8 forks source link

.ifne cannot compare Addresses #32

Closed bkrug closed 2 years ago

bkrug commented 2 years ago

Thank you for creating this extremely useful utility.

My assembly code contains the following code:

       .ifne $, >603E
       .error 'Directory of Addresses has moved. '
       .endif

When I assemble my code I get the following stack trace:

Traceback (most recent call last):
  File "C:\Program Files Uninstalled\xdt99-3.2.0\xas99.py", line 3443, in <module>
    status = main()
  File "C:\Program Files Uninstalled\xdt99-3.2.0\xas99.py", line 3340, in main
    asm.assemble(dirname, basename)
  File "C:\Program Files Uninstalled\xdt99-3.2.0\xas99.py", line 2272, in assemble
    self.symasm.assemble_pass_1(srcname)  # continue even with errors, to display them all
  File "C:\Program Files Uninstalled\xdt99-3.2.0\xas99.py", line 2143, in assemble_pass_1
    keep, add_label, operands, line = self.parser.prep.process(self, label, mnemonic, operands, line)
  File "C:\Program Files Uninstalled\xdt99-3.2.0\xas99.py", line 1460, in process
    fn(self, asm, operands)
  File "C:\Program Files Uninstalled\xdt99-3.2.0\xas99.py", line 1371, in IFNE
    self.parse = Util.cmp(*self.args(ops)) != 0 if self.parse else None
  File "C:\Program Files Uninstalled\xdt99-3.2.0\xas99.py", line 57, in cmp
    return (x > y) - (x < y)
TypeError: '>' not supported between instances of 'Address' and 'int'

I am using:

Thanks!

bkrug commented 2 years ago

I'm assembling using this command: xas99.py 'myfile.asm' -S -R -L 'myfile.lst'

endlos99 commented 2 years ago

Thanks for your report! At first I couldn't reproduce it, but then I found out that you must be assembling a relocatable program.

You could argue that comparing a relocatable address to something is not particular useful, since the relocatable address ($ in your case) might become something else altogether when the program is loaded into memory.

But I think it is still useful, and made a fix for it. Unfortunately, I cannot push it right now, since I'm working on the IDE plugins, but you should get it sometime next week. I'll let you know when I push it.

bkrug commented 2 years ago

Thanks, I'll look out for it.

And you're right I'm working with relocatable addresses, but am still interested in addresses relative to the beginning of the file. I'll probably change my original condition to:

   .ifne $, >3E

or

   .ifne >6000+$, >603E
endlos99 commented 2 years ago

Your fix has been release with version 3.3.0. Please check if it works for you now, and reopen this ticket if not.

Regarding your two comparisons, they're equivalent, but I'd prefer the simpler one. :-)

bkrug commented 2 years ago

Thanks for your help!

I started using 3.3.1, and the comparison with a relocatable address is now a warning instead of throwing an exception. My program assembles correctly.

endlos99 commented 2 years ago

I now have second thoughts about this warning. I think it should be fine, say, to compare the program size again an upper limit for relocatable programs. I'll remove the warning again in the next release.

endlos99 commented 2 years ago

Removed with 3.3.2.