GNU Info

Info Node: (nasm.info)Section 4.8.4

(nasm.info)Section 4.8.4


Next: Section 4.8.5 Prev: Section 4.8.3 Up: Section 4.8
Enter node , (file) or (file)node

4.8.4. `__FILE__' and `__LINE__': File Name and Line Number
-----------------------------------------------------------

   Like the C preprocessor, NASM allows the user to find out the file
name and line number containing the current instruction. The macro
`__FILE__' expands to a string constant giving the name of the current
input file (which may change through the course of assembly if
`%include' directives are used), and `__LINE__' expands to a numeric
constant giving the current line number in the input file.

   These macros could be used, for example, to communicate debugging
information to a macro, since invoking `__LINE__' inside a macro
definition (either single-line or multi-line) will return the line
number of the macro _call_, rather than _definition_. So to determine
where in a piece of code a crash is occurring, for example, one could
write a routine `stillhere', which is passed a line number in `EAX' and
outputs something like `line 155: still here'. You could then write a
macro

     %macro  notdeadyet 0
     
             push    eax
             mov     eax,__LINE__
             call    stillhere
             pop     eax
     
     %endmacro

   and then pepper your code with calls to `notdeadyet' until you find
the crash point.


automatically generated by info2www version 1.2.2.9