This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Is this correct ?


Hi,

I have this C code which is compiled using arm-linux-gcc 2.95.3
Using one ldr instruction should get to the value of prev_limit,
why does it take a sequence of two ldr instructions ? See below

static long all_requests;

long get_request(int n)
{
        static long prev_found = 0, prev_limit = 0;
        long req, limit;

        limit = all_requests + n;
        if (limit != prev_limit) {
                prev_limit = limit;
                prev_found = all_requests;
        }
        req = prev_found;

        return(req);
}

The compiled code is
.
.
long get_request(int n)
{
    80bc:       e50b0010        str     r0, [fp, -#16]
        static long prev_found = 0, prev_limit = 0;
        long req, limit;

        limit = all_requests + n;
    80c0:       e59f3054        ldr     r3, [pc, #54]   ; 811c
<get_request+0x70>
    80c4:       e5932000        ldr     r2, [r3]
    80c8:       e51b3010        ldr     r3, [fp, -#16]
    80cc:       e0822003        add     r2, r2, r3
    80d0:       e50b2018        str     r2, [fp, -#24]
        if (limit != prev_limit) {
    80d4:       e59f3044        ldr     r3, [pc, #44]   ; 8120
<get_request+0x74>
    80d8:       e51b2018        ldr     r2, [fp, -#24]
    80dc:       e5933000        ldr     r3, [r3]
    80e0:       e1520003        cmp     r2, r3
    80e4:       0a000006        beq     8104 <get_request+0x58>
                prev_limit = limit;
    80e8:       e59f3030        ldr     r3, [pc, #30]   ; 8120
<get_request+0x74>



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]