Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
C code:
typedef __int128 int128_t; int128_t add128(int128_t a, int128_t b) { return a + b; } int128_t sub128(int128_t a, int128_t b) { return a - b; } int128_t mul128(int128_t a, int128_t b) { return a * b; } int128_t div128(int128_t a, int128_t b) { return a / b; } int128_t rem128(int128_t a, int128_t b) { return a % b; }
Assembler generated by gcc -O3 -march=core2:
.file "lookatme.c" .text .p2align 4,,15 .globl add128 .type add128, @function add128: .LFB0: .cfi_startproc movq %rdx, %rax movq %rcx, %rdx addq %rdi, %rax adcq %rsi, %rdx ret .cfi_endproc .LFE0: .size add128, .-add128 .p2align 4,,15 .globl sub128 .type sub128, @function sub128: .LFB1: .cfi_startproc movq %rsi, %r10 movq %rdi, %rsi subq %rdx, %rsi movq %r10, %rdi sbbq %rcx, %rdi movq %rsi, %rax movq %rdi, %rdx ret .cfi_endproc .LFE1: .size sub128, .-sub128 .p2align 4,,15 .globl mul128 .type mul128, @function mul128: .LFB2: .cfi_startproc imulq %rdx, %rsi movq %rdx, %rax imulq %rdi, %rcx mulq %rdi addq %rcx, %rsi addq %rsi, %rdx ret .cfi_endproc .LFE2: .size mul128, .-mul128 .globl __divti3 .p2align 4,,15 .globl div128 .type div128, @function div128: .LFB3: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 call __divti3 addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3: .size div128, .-div128 .globl __modti3 .p2align 4,,15 .globl rem128 .type rem128, @function rem128: .LFB4: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 call __modti3 addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE4: .size rem128, .-rem128 .ident "GCC: (GNU) 4.6.0 20110207 (experimental) [trunk revisio +n 169884]" .section .note.GNU-stack,"",@progbits
So, it uses inlined 64bits arithmetic, except for division and modulo operations that are library calls.

In reply to Re^8: Module for 128-bit integer math? by salva
in thread Module for 128-bit integer math? by BrowserUk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (7)
    As of 2020-11-25 20:31 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found