Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. #include "stdafx.h"
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #include <stdio.h>
  4. #include <locale.h>
  5. #include <string.h>
  6.  
  7. short int assembler(char x, short int y, char z) {
  8.     short int v_as;
  9.     __asm  {
  10.         // считаем числитель
  11.         mov al, x;
  12.         cbw;
  13.         mov bx, y;
  14.         sub bx, 3;
  15.         imul bx;
  16.         mov cx, dx;
  17.         mov bx, ax;
  18.         add bx, 2;
  19.         sbb cx, dx;
  20.         // считаем знаменатель
  21.         mov al, z;
  22.         cbw;
  23.         add ax, 4;
  24.         xchg ax, bx;
  25.         idiv bx;
  26.         neg ax;
  27.         sub ax, 3;
  28.         mov v_as, ax;
  29.     }
  30.     return v_as;
  31. }
  32.  
  33. int main()
  34. {
  35.     char x, z;
  36.     short int y, v, v_as, v_c;
  37.     setlocale(LC_ALL, "Rus");
  38.     int i;
  39.     setlocale(LC_ALL, "Rus");
  40.     printf("Input the number of the test: ");
  41.     scanf_s("%d", &i);
  42.     switch (i)
  43.     {
  44.     case 1:
  45.     {
  46.         x = 0x3;
  47.         y = -0x1;
  48.         z = 0x1;
  49.         v = -0x1;
  50.         break;
  51.     }
  52.     case 2:
  53.     {
  54.         x = 0x6F;
  55.         y = 0x7FD6;
  56.         z = -0x7F;
  57.         v = 0x7357;
  58.         break;
  59.     }
  60.     default:
  61.         printf("The number is wrong\n");
  62.         break;
  63.     }
  64.     v_c = -(2 + x * (y - 3)) / (z + 4) - 3;
  65.     v_as = assembler(x, y, z);
  66.     printf("\nРасчет(Ассемблер):в 10: %d и в 16 %x", v_as, v_as);
  67.     printf("\nИстинный ответ: в 10 %d и в 16 %x \n", v, v);
  68.     printf("\nРасчет(СИ):в 10: %d и в 16 %x", v_c, v_c);
  69.     getchar();
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement