long long in assembly

Muschick Christian muschick_christian@aon.at
Thu Sep 16 13:44:00 GMT 2004


Hi!

>I am trying to increment a 64-bit counter in assembly code.
>In fact, it is a variable "unsigned long long" from C code, and
>I am trying to increment it from a function written in assembly.
>  
>
You can inspect the assembly code generated by gcc with the -S option.

Compiling this simple program

int main()
{
    unsigned long long a = 1234;
    a++;


    return a;
}

yields (only relevant lines)

    .loc 1 5 0
    movl    $1234, -8(%ebp)
    movl    $0, -4(%ebp)
    .loc 1 6 0
    leal    -8(%ebp), %eax
    addl    $1, (%eax)
    adcl    $0, 4(%eax)   // <- This should be what you are looking for
    .loc 1 9 0
    movl    -8(%ebp), %eax

greets
cm



More information about the Gcc-help mailing list