[cfe-users] clang x86 assembler 8-bit displacements
Zenith432 via cfe-users
cfe-users at lists.llvm.org
Tue Apr 26 12:17:24 PDT 2016
This time a question about the integrated assembler
------- code
.code32
.data
L1:
.quad 88
.equ L2, . - L1
.byte 29
.text
mov 55(%ebx), %eax
mov L2(%ebx), %eax
-------- end code
clang -c -o file.o file.s gives this
---------
0000000000000000 8b4337 movl 0x37(%rbx), %eax
0000000000000003 8b8308000000 movl 0x8(%rbx), %eax
---------
Both displacements fit in a signed 8-bit displacement. When a constant is given, cc1as know how to squeeze the opcode. The label L2 is local, and known even for a 1-pass assembler. Yet it doesn't know to squeeze the opcode, and uses a 32-bit signed displacement.
Same result if the symbols L1, L2 are in the .text section instead of .data.
Any way to tell cc1as to use the 8-bit displacement for an absolute symbol? gnu assembler has a form "mov.d8", and I believe it also knows to choose the 8-bit displacement automatically in this situation. clang doesn't seem to support .d8.
PS: Where in the clang sources is cc1as found? I couldn't make it out.
More information about the cfe-users
mailing list