How do the DY and DZ pseudo-instructions work in NASM?

Viewed 103

In nasm, pseudo-instructions like db can be used to declare initialized data. For example:

db 0, 1

Declares two bytes of initialized data, a 0 followed by a 1.

There are more types beyond db. The documentation says:

DB, DW, DD, DQ, DT, DO, DY and DZ (collectively "Dx" in this documentation) are used, much as in MASM, to declare initialized data in the output file. They can be invoked in a wide range of ways: ... DT, DO, DY and DZ do not accept integer numeric constants as operands.

However, it doesn't give examples of DY adn DZ use for initialized data.

Let's say I just want to declare a zmm register's worth of 0 bytes (64 bytes). How do I do it? As the documentation says "DT, DO, DY and DZ do not accept integer numeric constants as operands.", so dz 0 doesn't work, but it isn't clear what forms they do accept.

1 Answers

Apparently you can use string syntax

Strings enclosed in backquotes support C-style \–escapes for special characters.

...

The following escape sequences are recognized by backquoted strings:

...

\xFF Up to 2 hexadecimal digits - literal byte

So use

dz `\x00`
Related