Advertisement
Guest User

Untitled

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