Login
You're viewing the discuss.systems public feed.
  • Oct 13, 2026, 1:37 AM

    @steve something something dual carry chains with ADCX/ADOX.

    Not relevant for actual adds but does matter for muls.

    No idea how you handle loops when you have to.

    Presumably unroll and spill/restore carry/overflow into a designated landing pad reg around the test

    💬 1🔄 0⭐ 1

Replies

  • Oct 13, 2026, 1:44 AM

    @steve idly wondering whether you can do something like

    mov r8d, 0
    adcx r8d, r8d
    adox r8d, r8d
    shl r8d, 30

    to save and then

    add r8d, r8d

    to restore. That will give you carry back, but I always forget what exactly overflow was. Carry-in into MSB != carry-out, right?

    in this case carry-out from MSB is saved_CF and carry-in is saved_OF, so it would set OF to saved_OF^saved_CF.

    Almost. Pity. No actual use for it but it felt cute. :)

    💬 1🔄 0⭐ 1
  • Oct 13, 2026, 1:57 AM

    @steve anyway, with low-ish trip count, probably something like

    sub rdx, rsi
    sub rdi, rsi
    clc

    lp:
    mov rax, [rsi]
    adc rax, [rdx + rsi]
    mov [rdi + rsi], rax
    lea rsi, [rsi + 8]
    dec rcx
    jnz lp

    or maybe (probably not)

    lea rsi, [rsi + rcx*8]
    lea rdx, [rdx + rcx*8]
    lea rdi, [rdi + rcx*8]
    neg rcx
    jz skip

    clc
    lp:
    mov rax, [rsi + rcx*8]
    adc rax, [rdx + rcx*8]
    mov [rdi + rcx*8], rax
    inc rcx
    jnz lp

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 1