6

2 forms in constant declaration:

len equ 2
len: equ 2

Are they the same?

If not then what is the advantage or disadvantage of each declaration form?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Linh Dao
  • 1,305
  • 1
  • 19
  • 31

1 Answers1

11

The functional difference between these two:

len  equ 2
len: equ 2

is no difference at all. As stated on the NASM doc page:

NASM places no restrictions on white space within a line: labels may have white space before them, or instructions may have no space before them, or anything. The colon after a label is also optional.

(Note that this means that if you intend to code lodsb alone on a line, and type lodab by accident, then that's still a valid source line which does nothing but define a label. Running NASM with the command-line option -w+orphan-labels will cause it to warn you if you define a label alone on a line without a trailing colon.)

Community
  • 1
  • 1
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • I want to know the difference between "len equ 2" and "len: equ 2". Sorry if my question is unclear, i changed it. Please excuse my english. – Linh Dao Nov 04 '11 at 08:35
  • Sorry, @Linh, I misunderstood the original question to mean "what's the difference between equ and db?". Going back and rereading, the fault was clearly mine, not yours. – paxdiablo Nov 04 '11 at 08:40
  • @Linh, rather than waste a perfectly good answer (albeit to the wrong question), I've posted the original one at http://stackoverflow.com/questions/8006711/whats-the-difference-between-equ-and-db-in-nasm, to the _right_ question, if you're interested :-) – paxdiablo Nov 04 '11 at 08:48