Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 05:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found