I have the following code that prints the number of parameters passed to ./main. Notice the fmt in the rodata section. I\'ve included
When you use quotes or double quotes around a string in NASM, it doesn't accept C style escape sequences. On Linux you can encode \n as ASCII 10 like this:
fmt db "Number of parameters: %d", 10, 0
There is an alternative. NASM supports backquotes (backticks) which will allow NASM to process the characters between them as C style escape sequences. This should work as well:
fmt db `Number of parameters: %d \n`, 0
Please note: Those are not single quotes, but backticks. This is described in the NASM documentation:
3.4.2 Character Strings
A character string consists of up to eight characters enclosed in either single quotes ('...'), double quotes ("...") or backquotes (
...). Single or double quotes are equivalent to NASM (except of course that surrounding the constant with single quotes allows double quotes to appear within it and vice versa); the contents of those are represented verbatim. Strings enclosed in backquotes support C-style -escapes for special characters.