ID photo of Ciro Santilli taken in 2013 right eyeCiro Santilli OurBigBook logoOurBigBook.com  Sponsor 中国独裁统治 China Dictatorship 新疆改造中心、六四事件、法轮功、郝海东、709大抓捕、2015巴拿马文件 邓家贵、低端人口、西藏骚乱
c/mul_loop_asm_2.c
#include <stdlib.h>
#include <stdint.h>

int main(int argc, char **argv) {
    uint64_t max, i, x0, x1;
    if (argc > 1) {
        max = strtoll(argv[1], NULL, 0);
    } else {
        max = 1;
    }
    i = max;
    x0 = 1;
    x1 = 1;
#if defined(__x86_64__) || defined(__i386__)
    __asm__ (
        "mov $2, %%rbx;"
        ".align 64;"
        "loop:"

        "mov %[x0], %%rax;"
        "mul %%rbx;"
        "mov %%rax, %[x0];"

        "mov %[x1], %%rax;"
        "mul %%rbx;"
        "mov %%rax, %[x1];"

        "dec %[i];"
        "jne loop;"
        : [i] "+r" (i),
          [x0] "+r" (x0),
          [x1] "+r" (x1)
        :
        : "rax",
          "rbx" ,
          "rdx" 
    );
#endif
    return x0 + x1;
}

Ancestors (9)

  1. CPU microbenchmark
  2. Microarchitectural benchmark
  3. Microarchitecture
  4. Computer hardware
  5. Computer
  6. Information technology
  7. Area of technology
  8. Technology
  9. Home