开发者

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

Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_如何学运维

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago.

Improve this question

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


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


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:
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜