Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <locale.h>
- #include <string.h>
- short int assembler(char x, short int y, char z)
- {
- short int v_as;
- __asm
- {
- // считаем числитель
- mov al, x;
- cbw;
- sub ax, 2;
- mov bx, 7;
- imul bx;
- mov bx, y;
- add ax, bx;
- adc dx, 0;
- xchg bx, ax;
- // считаем знаменатель
- mov al, z;
- cbw;
- add ax, 4;
- xchg ax, bx;
- idiv bx;
- sub ax, 1;
- mov v_as, ax;
- }
- return v_as;
- }
- int main()
- {
- char x, z;
- short int y, v, v_as, v_c;
- setlocale(LC_ALL, "Rus");
- int i;
- setlocale(LC_ALL, "Rus");
- printf("Input the number of the test: ");
- scanf_s("%d", &i);
- switch (i)
- {
- case 1:
- {
- x = -0x1;
- y = 0x13;
- z = -0x2;
- v = -0x2;
- break;
- }
- case 2:
- {
- x = -0x7E;
- y = 0x4FBA;
- z = 0x7F;
- v = 0x93;
- break;
- }
- default:
- printf("The number is wrong\n");
- break;
- }
- v_c = ((7 * (x - 2) + y) / (z + 4)) - 1;
- v_as = assembler(x, y, z);
- printf("\nРасчет(Ассемблер):в 10: %d и в 16 %x", v_as, v_as);
- printf("\nИстинный ответ: в 10 %d и в 16 %x \n", v, v);
- printf("\nРасчет(СИ):в 10: %d и в 16 %x", v_c, v_c);
- getch();
- return 0;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement