I would like to write a gas macro to generate code containing various movdqu commands in the xmm register depending on the parameter n.
.macro xxmov n, p1 .if (\n == 1) xor %eax, %eax .endif .if (\n - 1) xxmov (\n - 1), \p1 .endif movdqu ((\n - 1)*0x10)(\p1), %xmm0 .endm xxmov 14, %rsi
After compiling the disassembled code,
0000000000000000 <.text>: 0: 31 c0 xor %eax,%eax 2: f3 0f 6f 06 movdqu (%rsi),%xmm0 6: f3 0f 6f 46 10 movdqu 0x10(%rsi),%xmm0 b: f3 0f 6f 46 20 movdqu 0x20(%rsi),%xmm0 10: f3 0f 6f 46 30 movdqu 0x30(%rsi),%xmm0 15: f3 0f 6f 46 40 movdqu 0x40(%rsi),%xmm0 1a: f3 0f 6f 46 50 movdqu 0x50(%rsi),%xmm0 1f: f3 0f 6f 46 60 movdqu 0x60(%rsi),%xmm0 24: f3 0f 6f 46 70 movdqu 0x70(%rsi),%xmm0 29: f3 0f 6f 86 80 00 00 movdqu 0x80(%rsi),%xmm0 30: 00 31: f3 0f 6f 86 90 00 00 movdqu 0x90(%rsi),%xmm0 38: 00 39: f3 0f 6f 86 a0 00 00 movdqu 0xa0(%rsi),%xmm0 40: 00 41: f3 0f 6f 86 b0 00 00 movdqu 0xb0(%rsi),%xmm0 48: 00 49: f3 0f 6f 86 c0 00 00 movdqu 0xc0(%rsi),%xmm0 50: 00 51: f3 0f 6f 86 d0 00 00 movdqu 0xd0(%rsi),%xmm0 58: 00
However, when I replaced% xmm0 with% xmm \ n in the above xxmov macro, I got a compilation error,
$ gcc -c mac.s mac.s: Assembler messages: mac.s:17: Error: bad register name `%xmm(((((((((((((14 - 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm((((((((((((14 - 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm(((((((((((14 - 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm((((((((((14 - 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm(((((((((14 - 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm((((((((14 - 1)- 1)- 1)- 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm(((((((14 - 1)- 1)- 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm((((((14 - 1)- 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm(((((14 - 1)- 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm((((14 - 1)- 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm(((14 - 1)- 1)- 1)' mac.s:17: Error: bad register name `%xmm((14 - 1)- 1)' mac.s:17: Error: bad register name `%xmm(14 - 1)'
So, is it anyway, can I manipulate my macro with the registration name xmm (from% xmm0 to% xmm_ {n-1})? I tried the \ @ (% xmm \ @) mentioned in http://sourceware.org/binutils/docs/as/Macro.html#Macro . However, this is not very good, because I would like to use this macro several times, while \ @ seems to grow monotonously.