问题
In the following compiler output:
a:
.long 4
b:
.byte 99
x:
.zero 4
c:
.byte 12
f:
.zero 4
What does the .zero
directive mean? It seems to be the only one not listed in the gas directives. Just from looking at the above, long
is four bytes, .byte
is one byte, and I'm guessing .zero
means zero-for-four-bytes (or whatever the number is after the directive). Is that correct?
If so, why not just do .long 0
. Does this put it in a different section or something?
回答1:
No, it doesn't put it in a different section, it just puts it inline in whatever section you're currently creating.
In terms of its relationship to .long
, the latter actually depends on the architecture. It could be a different size and/or endianness. Note the endianness probably won't matter for the zero value but the size may.
The .zero
directive, on the other hand, is an alias for .skip
(and .space
on some architectures), and generates the requested number of bytes regardless of architecture.
Also keep in mind that, as an alias of .skip
, you can also provide the value you want used for the bytes (it defaults to zero) but it makes little sense to do something like:
.zero 4, 32
to generate four spaces :-)
来源:https://stackoverflow.com/questions/65641034/what-is-zero-in-gnu-gas