Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- char s[100];
- int res;
- cin.getline(s, 100);
- _asm {
- xor ecx, ecx
- xor ebx, ebx
- xor edx, edx
- lea esi, s
- _loop1:
- mov bl, byte ptr [esi]
- sub bl, '0'
- imul ecx, 10
- add ecx, ebx
- inc esi
- cmp byte ptr [esi], '+'
- je _endl1
- cmp byte ptr [esi], '-'
- je _endl1
- cmp byte ptr [esi], '*'
- je _endl1
- cmp byte ptr [esi], '/'
- je _endl1
- jmp _loop1
- _endl1:
- mov al, byte ptr [esi]
- _loop2:
- inc esi
- cmp byte ptr [esi], 0
- je _endl
- mov bl, byte ptr [esi]
- sub bl, '0'
- imul edx, 10
- add edx, ebx
- jmp _loop2
- _endl:
- push eax
- mov eax, ecx
- mov ebx, edx
- pop ecx
- cmp cl, '-'
- jne _plus
- sub eax, ebx
- jmp _end
- _plus:
- cmp cl, '+'
- jne _mul
- add eax, ebx
- jmp _end
- _mul:
- cmp cl, '*'
- jne _div
- imul ebx
- jmp _end
- _div:
- cdq
- idiv ebx
- _end:
- mov res, eax
- }
- cout << (int)res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment