I want to add two numbers that have 12 bytes and to store the result in a 16 bytes var. How can i do this?
section .data
big_num1 dd 0x11111111, 0x22222222,
Elementary school:
1234
+ 5678
========
start filling it in
1
1234
+ 5678
========
2
4+8 = 12, so 2 carry the one.
in a computer you would add a = 4 + 8 adc b = 3 + 7 adc c = 2 + 6 adc d = 1 + 5
then dcba contain your result, it scales as wide as you want. d,c,b,a can be 8 bit, 16 bit, 32 bit or 64 bit depending on the instruction set. most have add and adc if they have flags, the ones that dont have flags then you can synthesize them in various ways that are not difficult at all... (break your operands into 16 bit quantities using 32 bit registers/memory do the 32 bit add now bit 16 is your carry out, add that into the next 16 bit chunk, takes some shifting and masking but it all works the same, since you probably have adc then you dont need to do any of that just do the trivial add, adc,adc, adc... until done.
If you clear the flag before you start you can use adc in a loop.
Now if your variables do not line up with the adder in the processor then you do have to synthesize it in some way.
Grade school math for the same problem, now you have to do the columns separately.
4
+ 8
====
12
and you have to manually mask and shift the result (12>>1) % 9 = 1 in base 10.
1
3
+ 7
====
11
then
1
2
+ 6
====
9
this one carries the zero
0
1
+ 5
====
6