Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #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;
- mov bx, y;
- sub bx, 3;
- imul bx;
- mov cx, dx;
- mov bx, ax;
- add bx, 2;
- sbb cx, dx;
- // считаем знаменатель
- mov al, z;
- cbw;
- add ax, 4;
- xchg ax, bx;
- idiv bx;
- neg ax;
- sub ax, 3;
- 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 = 0x3;
- y = -0x1;
- z = 0x1;
- v = -0x1;
- break;
- }
- case 2:
- {
- x = 0x6F;
- y = 0x7FD6;
- z = -0x7F;
- v = 0x7357;
- break;
- }
- default:
- printf("The number is wrong\n");
- break;
- }
- v_c = -(2 + x * (y - 3)) / (z + 4) - 3;
- 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);
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement