Thread: X86-64 addq

    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    149
    Rep Power
    36

    X86-64 addq


    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?
  2. #2
  3. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,805
    Rep Power
    1570
    Actually, it isn't because it is an incorrect source operand; if you had written,
    Code:
    addq %r9, %r8d
    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.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    149
    Rep Power
    36
    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!

IMN logo majestic logo threadwatch logo seochat tools logo