79082674

Date: 2024-10-13 07:56:45
Score: 0.5
Natty:
Report link

Is what I've been told/what I've gathered wrong?

In your scenario, it involves reading a 64-bit hardware timer stored in two separate 32-bit memory-mapped registers. It's crucial that using volatile keyword to ensure the compiler does not optimize away these memory accesses.

int main() {
    volatile uint32_t *ap = 0x1000;
    volatile uint32_t *bp = 0x1004;

    uint64_t temp = ((uint64_t)(*bp) << 32) | (*ap);
    
    if (temp > 0x2000) {
        return 0;
    }

    return 1;
}
Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Shelton Liu