Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.
1093 Discussions

GNU-style: Label(B3:) hello.cc(102): error: expected a ")"

srimks
New Contributor II
371 Views
Hello,

I have a piece of GNU-style Inline asm syntax code as below -

---------
void (x,x,x,x,x)
{
__asm__(
"pushq %rbp \n\t"
"movq %rsp,%rbp \n\t"
"subq $4, %rsp \n\t"

"movq 150%rbp, %rsp \n\t"
"movq 158%rbp, %rdi \n\t"
"movq 166%rbp, %rsi \n\t"
"movq 170%rbp, %rdx \n\t"
"movq 174%rbp, %rcx \n\t"


"movq %rdi, %r9 \n\t"
"movq %rdx, %r8 \n\t"
"movslq %ecx, %r10 \n\t"


"xorl %edi, %edi \n\t"
"xorl %ecx, %ecx \n\t"
"xorl %eax, %eax \n\t"

"testq %r9, %r9 \n\t"
"jle B12 \n\t"

"movq %r10, 48%rsp \n\t"
"movq %rdx, 56%rsp \n\t"
............................................
......in btw some more inst......
............................................

"movq %r8, %r13 \n\t"
"movq%r9, %r14 \n\t"

B3:; L#102
"movsd 208(%rsp,%r12,8), %xmm0 \n\t"
"movsd %rip, %xmm1 \n\t"
"call fmod \n\t"

"movsd %xmm0, 80%rsp \n\t"

"movsd 80%rsp, %xmm0 \n\t"
"call sin\n\t"

"movaps %xmm9,%xmm0 \n\t"

"movsd80%rsp, %xmm0 \n\t"
"movsd %xmm9, 88%rsp \n\t"
"call cos\n\t"

"movsd 88%rsp, %xmm9\n\t

...................................................................
...............in btw some more inst....................
...................................................................

"cvtsd2ss %xmm13, %xmm11 \n\t"
"movss %xmm11, 8(%r11,%r14) \n\t"
"jl B8 \n\t"

B10:
"addq $8192, %r13 \n\t"
"addq $8192, %rbp \n\t"
"addq $12, %rbx \n\t"
"incq%r12 \n\t"
"cmpq 48(%rsp), %r12 \n\t"
"jl B3 \n\t"

"movq 40(%rsp), %rbx \n\t"

..........................................................
..........................................................
----------------xxx----xxx------------------

On compiling on Linux x86_64 using ICC-v11.0, I get below error messages for label B3 only as below, remaining all labels are fine -

-----
EPDBQSTATE -I./../acro/include -Wall -O3 -g -O3 -fasm-blocks -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.cc
hello.cc(102): error: expected a ")"
B3:
^

hello.cc(327): warning #12: parsing restarts here after previous syntax error
);
^

hello.cc(56): remark #869: parameter "now" was never referenced
void hello( const State now,
^

hello.cc(57): remark #869: parameter "crd" was never referenced
Real crd[MAX_ATOMS][SPACE],
^

hello.cc(58): remark #869: parameter "v" was never referenced
const Real v[MAX_TORS][SPACE],
^

hello.cc(59): remark #869: parameter "tlist" was never referenced
const int tlist[MAX_TORS][MAX_ATOMS],
^

hello.cc(60): remark #869: parameter "ntor" was never referenced
const int ntor )
^

compilation aborted for hello.cc (code 2)
make: *** [hello.o] Error 2
---

Queries:
(a) How to resolve above error messages for L#102?

(b) Since this section is a part from single file which has multiple C/C++ files as a multi-package; sin, cos & fmod operation has been used here. Since these "sin, cos & fmod" has been referred by multiple files by almost all files as seen from objdump of the orignal source code. Over here, how should I call this sin, cos & fmod?


Looking for some clue??

~BR
0 Kudos
4 Replies
neni
New Contributor II
371 Views
B3: is part of your asm syntax - I think it should be in "B3: nt" as well

0 Kudos
srimks
New Contributor II
371 Views
Quoting - neni
B3: is part of your asm syntax - I think it should be in "B3: nt" as well

yeah, the qoute has to be provided, Thanks

I tried using GCC-v4.4 alongwith Binutils -v 2.18.50.0.9, I get asm error messages alongwith some peculiar behaviour too as below. The complete file code ends with last line # 234 but the I get error messages with GCC-v4.4 as -

---
ro/include -Wall -O3 -g -O3 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.cc
hello.cc: Assembler messages:
hello.cc:265: Error: suffix or operands invalid for `movsd'
hello.cc:275: Error: suffix or operands invalid for `movsd'
hello.cc:276: Error: suffix or operands invalid for `movslq'
hello.cc:283: Error: invalid char '[' beginning operand 2 `['
hello.cc:295: Error: suffix or operands invalid for `movq'
hello.cc:298: Error: bad register name `%3'
make: *** [hello.o] Error 1

----

The above line numbers are not present in the file as the file ends with last line number being 234.

Should I conclude that the assembly statements which has been written for this Inline GNU-syntax asm code are not valid 64-bit asm.

But I got the same .S as an output file when doing "icpc -g -O3 -S hello.cc -fasm-blocks".

Below (Reply#3) is the snapshot with ICC-v11.0 on Linux x86_64.

~BR
0 Kudos
srimks
New Contributor II
371 Views
Quoting - neni
B3: is part of your asm syntax - I think it should be in "B3: nt" as well

Intel C++ Compiler-v11.0 gives me below error messages -

---
hello.cc(60): remark #869: parameter "ntor" was never referenced
const int ntor )
^
/tmp/icpcY6IKlqas_.s: Assembler messages:
/tmp/icpcY6IKlqas_.s:58: Error: suffix or operands invalid for `movsd'
/tmp/icpcY6IKlqas_.s:68: Error: suffix or operands invalid for `movsd'
/tmp/icpcY6IKlqas_.s:69: Error: suffix or operands invalid for `movslq'
/tmp/icpcY6IKlqas_.s:76: Error: invalid char '[' beginning operand 2 `['
/tmp/icpcY6IKlqas_.s:88: Error: suffix or operands invalid for `movq'
/tmp/icpcY6IKlqas_.s:91: Error: bad register name `%3'
make: *** [torsion.o] Error 1

---

There is asm error messages difference (Reply#2 & Reply#3) generated by GCC-v4.4 (alongwith Binutils v-2.18.50.0.9) & ICC-v11.0. I am not sure which Binutils version ICC-v11.0 uses.

Also, the line# as shown in asm error messages (58, 68, 69, 76, 88 & 91) doesn't match the Inline-asm code within hello.cc.

~BR


0 Kudos
srimks
New Contributor II
371 Views
Quoting - srimks
Intel C++ Compiler-v11.0 gives me below error messages -

---
hello.cc(60): remark #869: parameter "ntor" was never referenced
const int ntor )
^
/tmp/icpcY6IKlqas_.s: Assembler messages:
/tmp/icpcY6IKlqas_.s:58: Error: suffix or operands invalid for `movsd'
/tmp/icpcY6IKlqas_.s:68: Error: suffix or operands invalid for `movsd'
/tmp/icpcY6IKlqas_.s:69: Error: suffix or operands invalid for `movslq'
/tmp/icpcY6IKlqas_.s:76: Error: invalid char '[' beginning operand 2 `['
/tmp/icpcY6IKlqas_.s:88: Error: suffix or operands invalid for `movq'
/tmp/icpcY6IKlqas_.s:91: Error: bad register name `%3'
make: *** [torsion.o] Error 1

---

There is asm error messages difference (Reply#2 & Reply#3) generated by GCC-v4.4 (alongwith Binutils v-2.18.50.0.9) & ICC-v11.0. I am not sure which Binutils version ICC-v11.0 uses.

Also, the line# as shown in asm error messages (58, 68, 69, 76, 88 & 91) doesn't match the Inline-asm code within hello.cc.

~BR



I made all above issues and errors resolved,the GNU-syntax Inline asm code is working fine now.TX ISN

~BR
0 Kudos
Reply