-2

How I make an addition of two numbers of 32 bits in Assembly using ADC?

ebed
  • 1
  • 1
  • 1

2 Answers2

1

Assuming an 8 bit processor with ld, st, adc and add and index registers X & Y which point to the values to be added, result replaces *X:

ld 3,X
add 3,Y   ; The first add is without carry
st 3,X
ld 2,X
adc 2,Y   ; subsequent adds propagate carry.
st 2,X
ld 1,X
adc 1,Y
st 1,X
ld 0,X
adc 0,Y
st 0,X
Richard Pennington
  • 19,673
  • 4
  • 43
  • 72
0

ADC stands for "ADd with Carry", in fact it is like add two values and add again the value of the carry flag:

adc eax,ebx

is like:

add eax, ebx
add eax, cf

or:

add eax, ebx
jnc dont_add
inc eax

dont_add:
...
BlackBear
  • 22,411
  • 10
  • 48
  • 86