November 2nd, 2012, 08:13 AM
For the instruction addq in one of my .s files I have the following error from gcc: suffix or operands invalid for `add'
I'm using Red Hat Linux.
The offending line is: addq %r8d, %r9
My guess is that 32 bit registers aren't allowed as source operands for addq, but I can't confirm this guess because I can't seem to find material using google that tells me what the legal operands are for addq specifically enough. I thought a 32 bit register would be fine since a 32 bit immediate is a legal source operand.
Is my guess correct?
November 2nd, 2012, 12:35 PM
Actually, it isn't because it is an incorrect source operand; if you had written,
then it would have been fine. The problem is that you are also using the doubleword register as the destination register, and it is too small for that.
EDIT: Wait a moment here; this is with the AT&T syntax, which has the destination as the second argument, right? I am probably wrong about that, then. Not sure where the problem lies in that case.
Last edited by Schol-R-LEA; November 2nd, 2012 at 12:39 PM.
November 2nd, 2012, 03:10 PM
Yes the destination is the second argument. I got an answer on this from my instructor: 32 bit registers are not legal operands for addq apparently. I'm working on a compiler and had to allocate a 64 bit register instead, no big deal. Thanks for the reply though!