GNU Info

Info Node: (nasm.info)Section 3.5

(nasm.info)Section 3.5


Next: Section 3.5.1 Prev: Section 3.4.4 Up: Chapter 3
Enter node , (file) or (file)node

3.5. Expressions
================

   Expressions in NASM are similar in syntax to those in C.

   NASM does not guarantee the size of the integers used to evaluate
expressions at compile time: since NASM can compile and run on 64-bit
systems quite happily, don't assume that expressions are evaluated in
32- bit registers and so try to make deliberate use of integer
overflow. It might not always work. The only thing NASM will guarantee
is what's guaranteed by ANSI C: you always have _at least_ 32 bits to
work in.

   NASM supports two special tokens in expressions, allowing
calculations to involve the current assembly position: the `$' and `$$'
tokens.  `$' evaluates to the assembly position at the beginning of the
line containing the expression; so you can code an infinite loop using
`JMP $'. `$$' evaluates to the beginning of the current section; so you
can tell how far into the section you are by using `($-$$)'.

   The arithmetic operators provided by NASM are listed here, in
increasing order of precedence.

Section 3.5.1
`|': Bitwise OR Operator
Section 3.5.2
`^': Bitwise XOR Operator
Section 3.5.3
`&': Bitwise AND Operator
Section 3.5.4
`<<' and `>>': Bit Shift Operators
Section 3.5.5
`+' and `-': Addition and Subtraction Operators
Section 3.5.6
`*', `/', `//', `%' and `%%': Multiplication and Division
Section 3.5.7
Unary Operators: `+', `-', `~' and `SEG'

automatically generated by info2www version 1.2.2.9