The .quad
directive is used to define 64 bit numeric value(s). In similar way how .byte
directive works.
.quad 0x123456789ABCDEF0, 2, 3
will compile to 24 bytes:
F0 DE BC 9A 78 56 34 12 02 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00
(for comparison, .byte 0x12, 2, 3
will compile to three bytes 12 02 03
).
Where and when is .quad usually called in assembly?
Uhm.. it's assembler directive, used during compilation, it will just produce machine code. It can't be "called". You can call/execute the machine code defined by it, but that's very rare usage pattern, to produce instructions by defining them in numeric way as opcodes, if you have at hand assembler which can produce it from the mnemonics instead.
Also, why use .quad to generate anything?
If you want to set up 64b number 1000000000000 (1e12) in data segment, it is much more convenient to define it as .quad 1000000000000
than calculating the separate byte values and defining it as .byte 0, 16, 165, 212, 232, 0, 0, 0
, in the .quad
case the assembler will do the parsing and splitting into bytes for you.
.quad .L3
(from comment)
.L3
is label somewhere in the code, so it is some memory address, so it is some 64 bit number (for x86 64b target platforms with flat memory mapping). If you want to have that value somewhere in memory, then using .quad .L3
is simple way how to produce 8 bytes with that value (address of .L3
label).
The switch
code does it use for indirect jump, selecting particular value in memory indexed by the switch value, and then jumping to the address stored in memory in the table. Something like jmp [table + index*8]
, when table+index*8
points at .L3
value, then the jmp
will jump to .L3
address.
0x123456789ABCDEF0
is stored as bytesF0 DE BC 9A 78 56 34 12
). – Precursor.quad .L3
comes from a segment of c code where there is a switch. – Aaron.L3
is a label, so it resolves to some address, which is a value that you can store – Derisive.quad .L3
would be as 8 bytes, and if you would check the actual value, you would find it equal to the address of.L3
label (ie. value of.L3
symbol in symbol table). BTW, that's not PIC/PIE compatible technique of compiling switch, I thought most of the 64b targets on x86 are enforced to be PIE, apparently I was wrong. (you could have provided some minimal examples in the question, like that.L3
label, that would explain tags + what is the actual question) – Precursor.quad
and some don't. Even amongst the assemblers that support.quad
, it might not universally mean the same thing. So which assembler are you using? – Sailboat