linux-mips
[Top] [All Lists]

why not put 64 bit value directly to register

To: linux-mips@linux-mips.org
Subject: why not put 64 bit value directly to register
From: "Bin Chen" <binary.chen@gmail.com>
Date: Wed, 26 Apr 2006 12:49:45 +0800
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=kyIWOFmIU/HZZz8MisF8QSHlKtL6wIoCwJN3zZOwYwAoLi1smF5UCcHsthWQjXkpIyr3PkHbsDsKlkM0spDHJLaqubKioCmGgf+z4yK5Ly+oa3qDXzp9IyNrdq64HWWhGuai+Sz//rExfDVg4+SYc7tFJNazD6/yWuDGHU/aGXg=
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Hi,

This code is snip from u-boot, I don't know why the 32bit-64bit conversion is needed, why not put val directly to register but do the transform?

static void cvmx_write_cop0_entry_lo_0(uint64_t val)
{
    uint32_t val_low  = val & 0xffffffff;
    uint32_t val_high = val  >> 32;

    uint32_t tmp; /* temp register */

    asm volatile (
        "  .set mips64                       \n"
        "  .set noreorder                    \n"
        /* Standard twin 32 bit -> 64 bit construction */
        "  dsll  %[valh], 32                 \n"
        "  dla   %[tmp], 0xffffffff          \n"
        "  and   %[vall], %[tmp], %[vall]    \n"
        "  daddu %[valh], %[valh], %[vall]   \n"
        /* Combined value is in valh */
        "  dmtc0 %[valh],$2,0                \n"
        "  .set reorder                      \n"
         :[tmp] "=&r" (tmp) : [valh] "r" (val_high), [vall] "r" (val_low) );
}

Thanks.
B.C

<Prev in Thread] Current Thread [Next in Thread>