Tranvick

Lena

Jun 24th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     char s[100];
  7.     int res;
  8.     cin.getline(s, 100);
  9.     _asm {
  10.         xor ecx, ecx
  11.         xor ebx, ebx
  12.         xor edx, edx
  13.         lea esi, s
  14. _loop1:
  15.         mov bl, byte ptr [esi]
  16.         sub bl, '0'
  17.         imul ecx, 10
  18.         add ecx, ebx
  19.         inc esi
  20.         cmp byte ptr [esi], '+'
  21.         je _endl1
  22.         cmp byte ptr [esi], '-'
  23.         je _endl1
  24.         cmp byte ptr [esi], '*'
  25.         je _endl1
  26.         cmp byte ptr [esi], '/'
  27.         je _endl1
  28.         jmp _loop1
  29. _endl1:
  30.         mov al, byte ptr [esi]
  31. _loop2:
  32.         inc esi
  33.         cmp byte ptr [esi], 0
  34.         je _endl
  35.         mov bl, byte ptr [esi]
  36.         sub bl, '0'
  37.         imul edx, 10
  38.         add edx, ebx
  39.         jmp _loop2
  40. _endl:
  41.         push eax
  42.         mov eax, ecx
  43.         mov ebx, edx
  44.         pop ecx
  45.  
  46.         cmp cl, '-'
  47.         jne _plus
  48.         sub eax, ebx
  49.         jmp _end
  50. _plus:
  51.         cmp cl, '+'
  52.         jne _mul
  53.         add eax, ebx
  54.         jmp _end
  55. _mul:
  56.         cmp cl, '*'
  57.         jne _div
  58.         imul ebx
  59.         jmp _end
  60. _div:
  61.         cdq
  62.         idiv ebx
  63. _end:
  64.         mov res, eax
  65.     }
  66.     cout << (int)res << endl;
  67.     return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment