NASM Forum > Using NASM

Make NASM print warning when operands aren't of same size.

(1/1)

niccolo:
Look at the following code:


--- Code: ---  segment .text

     mov eax, x
     mov ebx, y

     ...

  segment .data

     x DW 10
     y DW 1

--- End code ---

It has a bug: 'x' and 'y' are defined with 'dw' (16 bits) instead of 'dd' (32 bits). And they're assigned to 32 bits registers.

How can I make NASM print a warning in this case? If it's not possible, is there some way to guard against such bugs?

I've run nasm with the '-w+all' command line option, but it prints no warning.

(I'm new to Assembly.)

niccolo:
Oh my, I've found the following in the manual:


--- Quote ---  2.2.3 NASM Doesn't Store Variable Types

  NASM, by design, chooses not to remember the types of variables you declare.

--- End quote ---

So I guess that's it.

(Anyway, if anybody has tips on how not to trip on this, I'm all ears.)

Navigation

[0] Message Index

Go to full version