Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- push esi;
- push edi;
- push eax;
- push ebx;
- push ecx;
- push edx;
- // START CODING HERE
- mov esi, 0; // currNum1
- mov edi, 0; //currNum2
- mov edx, 0; // currNum3
- mov ecx, 0; //carry = 0
- WhileLoop:
- cmp posNum3, 0;
- JL WhileFalse;
- mov esi, 0; // currNum1 = currNum2 = 0
- mov edi, 0;
- cmp posNum1, 0; // if posNum1 > 0;
- Jg if1;
- jmp skip;
- if1:
- sub posNum1, 1; // posNum1--
- mov ebx, posNum1; // ebx = posnum1
- mov eax, num1 ;// eax points to the beggining of the char array
- movsx eax, [eax + ebx] ;// ebx is the index
- mov esi, eax; // currnum1 = num1[posNum1]
- sub esi, '0'; // currnum1 = currnum1 - '0'
- skip:
- cmp posNum2, 0; // if posNum1 > 0;
- Jg if2;
- jmp skip2;
- if2: // like if 1, no comments here, if if1 is messed up if2 will be
- sub posNum2, 1;
- mov ebx, posNum2;
- mov eax, num2 ;// eax points to the beggining of the string
- movsx eax, [eax + ebx] ;// ebx is the index
- mov edi, eax;
- sub edi, '0';
- skip2:
- mov edx, esi; // currNum3 = currNum1 + currNum2 + carry;
- add edx, edi;
- add edx, ecx;
- mov ecx, 0; // carry = 0
- cmp edx, 10; // if currNum3 >= 10
- jge if3;
- jmp skip3;
- if3:
- sub edx, 10; // currNum3 = currNum3 - 10
- mov ecx, 1; // carry = 1
- skip3:
- sub posNum3, 1;
- //resNum[posNum3] = currNum3 + '0';
- mov edx, posNum3
- mov esi, resNum
- add al, '0'
- mov byte ptr [edx+esi], al
- jmp WhileLoop;
- WhileFalse:
- // END CODING HERE
- pop edx;
- pop ecx;
- pop ebx;
- pop eax;
- pop edi;
- pop esi;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement