Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. short i, n, num;
  5.  
  6. void HowMany()
  7. {
  8. cout << "How many numbers would you like to try?" << endl;
  9. cin >> n;
  10. }
  11.  
  12. void IntegerNumber()
  13. {
  14. cout << "Enter an integer Number" << endl;
  15. cin >> num;
  16. }
  17. void DisplayEven()
  18. {
  19. cout << num << ", is EVEN" << endl;
  20.  
  21. }
  22. void DisplayOdd()
  23. {
  24. cout << num << ", is ODD" << endl;
  25. }
  26.  
  27. int main()
  28. {
  29. _asm
  30. {
  31. call HowMany;//calls HowMany
  32. Loop1:
  33. cmp n, 0;//compares n to 0
  34. je done;// if 0, then done
  35. call IntegerNumber;//calls IntegerNumber
  36. dec n;//--n, every time it loops
  37. mov ax, num;//ax=num, stored as binary
  38. and ax, 1;//AND's ax to 1, output is either 0 or 1
  39. cmp ax, 1;//compares that 0 or 1 to 1
  40. je Odd1;//if ax(last bit) is 1, then go to Odd1
  41. Even1://else, is ax(last bit) is 0, jmp to Even1
  42. call DisplayEven;//calls DisplayEven
  43. jmp Loop1;//jump to Loop1
  44. Odd1:
  45. call DisplayOdd;
  46. jmp Loop1;//jump to Loop1
  47. done:
  48. }
  49. system("pause");
  50. }
  51. /*
  52. Name: Maximiliano Rodriguez
  53. Project: Project 6 Question 2
  54.  
  55. How many numbers would you like to try?
  56. 4
  57. Enter an integer Number
  58. 124
  59. 124, is EVEN
  60. Enter an integer Number
  61. 37
  62. 37, is ODD
  63. Enter an integer Number
  64. 3456
  65. 3456, is EVEN
  66. Enter an integer Number
  67. 555
  68. 555, is ODD
  69. Press any key to continue . . .
  70.  
  71. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement