Cosmin
Cosmin

Reputation: 2214

Addition of two 64 bit numbers in emu8086

I've searched for about one day but I can't find anything about adding 64 bit numbers in assembly - emu8086

How can I do this ?

My registers are only 16 bit and I have 2 numbers of 64 bits. The application I am using it's emu8086. (it's for a school project)

Upvotes: 1

Views: 7014

Answers (1)

Alexey Frunze
Alexey Frunze

Reputation: 62048

Use adc to propagate carries between individual 16-bit additions. The following will add number 2 from memory to number 1 in memory:

mov ax, [num1_bits0_15]
add ax, [num2_bits0_15]
mov [num1_bits0_15], ax

mov ax, [num1_bits16_31]
adc ax, [num2_bits16_31]
mov [num1_bits16_31], ax

mov ax, [num1_bits32_47]
adc ax, [num2_bits32_47]
mov [num1_bits32_47], ax

mov ax, [num1_bits48_63]
adc ax, [num2_bits48_63]
mov [num1_bits48_63], ax

Upvotes: 6

Related Questions