Author Topic: A simple calculation goes wrong  (Read 11280 times)

Offline RuudB

  • Jr. Member
  • *
  • Posts: 40
  • Country: nl
    • Ruud's Commodore Site
A simple calculation goes wrong
« on: February 07, 2019, 08:39:28 AM »
I'm busy creating a diagnostic ROM for the IBM-AT and compatibles. I'll need a 32 KB EPROM but I think I only need 16 KB for the actual code. So:

  org 8000h

  setloc 0C000h    ; macro that fills range between this address and last code with 0FFh

L_start:
   .....  code  ...

I want to calculate the checksum of the EPROM as part of the test. The number of bytes to test is 64 KB minus the starting address, thus:

  mov  cx,10000h-L_start

and here I get an error: invalid operand type. If I replace the minus with a plus, things go fine where I maybe would expect a kind of "number too big" error. Using "strict word" does not help.  I could calculate the checksum of the whole ROM as work around but I'm sure I will need the above calculation again. So I would like to know what is going on.

Thank you in advance for any help!

Kind regards, Ruud Baltissen

« Last Edit: February 07, 2019, 08:55:51 AM by RuudB »
With kind regards / met vriendelijke groet, Ruud Baltissen

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: A simple calculation goes wrong
« Reply #1 on: February 07, 2019, 10:41:58 PM »
Hi Ruud,

I am unable to duplicate the "invalid operand type" error. Double check what you're telling Nasm, including making sure your editor is outputting ascii.

I am seeing Nasm silently truncate 10000h without issuing the warning I would expect. Bug?

Best,
Frank


Offline RuudB

  • Jr. Member
  • *
  • Posts: 40
  • Country: nl
    • Ruud's Commodore Site
Re: A simple calculation goes wrong
« Reply #2 on: February 08, 2019, 07:35:51 AM »
I was able to bring the source back to this bare minimum:


   org   08000h
L_start:
   mov   cx,10000h-L_start


FYI: I'm using NASM 2.11.08 from 2015.

Command: nasm.exe %1.asm -f bin -l %1.lst -o %1.bin

 I attached a printscreen of the DOS window.
With kind regards / met vriendelijke groet, Ruud Baltissen

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: A simple calculation goes wrong
« Reply #3 on: February 08, 2019, 04:50:15 PM »
I am simply unable to duplicate this error. I'm using nasm-2.14.03rc2 - just upgraded to the latest version.

It looks to me like what you'd get if your editor were not producing ascii text. That's not only my best guess, it's my only guess... Wish I could help you more!

Best,
Frank


Offline RuudB

  • Jr. Member
  • *
  • Posts: 40
  • Country: nl
    • Ruud's Commodore Site
Re: A simple calculation goes wrong
« Reply #4 on: February 09, 2019, 02:56:06 PM »
Hallo Frank,

I just upgraded to 2.14.02 and that one works fine. So it was indeed the version.
Thank you!

Kind regards, Ruud Baltissen
With kind regards / met vriendelijke groet, Ruud Baltissen

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: A simple calculation goes wrong
« Reply #5 on: February 09, 2019, 10:00:05 PM »
Okay. That's a surprise to me - I didn't know there were bugs of that sort in that version. We live and learn! Glad you got it working!

Best,
Frank