Wrong result when adding two bignums in gass assembler

36 Views Asked by At

I am adding two big numbers in GAS, I have used the online big number calculator to check the sum first, which is -396,154,063,093,444,159,558. I also am using SASM, an asm IDE, and the result from rcx is 0x86420a87db9357ba; from rdx is 0xffffffffffffffea. Combining them results in 0xffffffffffffffea86420a87db9357ba, which is, in decimal, 340282366920938463067220544338324051898. What have I done wrong? Here is the code:


    .section .data
bignum1:
    .octa -198077031546722079779 
bignum2:
    .octa -198077031546722079779
.text
.global main
main:
    movq %rsp, %rbp #for correct debugging
    # write your code here
    movq bignum1, %rax
    movq bignum1 +8, %rbx
    movq bignum2, %rcx
    movq bignum2 + 8, %rdx
    
    addq %rax, %rcx
    adcq %rbx, %rdx    
    
    movq $60, %rax
    syscall

0

There are 0 best solutions below