Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- short i, n, num;
- void HowMany()
- {
- cout << "How many numbers would you like to try?" << endl;
- cin >> n;
- }
- void IntegerNumber()
- {
- cout << "Enter an integer Number" << endl;
- cin >> num;
- }
- void DisplayEven()
- {
- cout << num << ", is EVEN" << endl;
- }
- void DisplayOdd()
- {
- cout << num << ", is ODD" << endl;
- }
- int main()
- {
- _asm
- {
- call HowMany;//calls HowMany
- Loop1:
- cmp n, 0;//compares n to 0
- je done;// if 0, then done
- call IntegerNumber;//calls IntegerNumber
- dec n;//--n, every time it loops
- mov ax, num;//ax=num, stored as binary
- and ax, 1;//AND's ax to 1, output is either 0 or 1
- cmp ax, 1;//compares that 0 or 1 to 1
- je Odd1;//if ax(last bit) is 1, then go to Odd1
- Even1://else, is ax(last bit) is 0, jmp to Even1
- call DisplayEven;//calls DisplayEven
- jmp Loop1;//jump to Loop1
- Odd1:
- call DisplayOdd;
- jmp Loop1;//jump to Loop1
- done:
- }
- system("pause");
- }
- /*
- Name: Maximiliano Rodriguez
- Project: Project 6 Question 2
- How many numbers would you like to try?
- 4
- Enter an integer Number
- 124
- 124, is EVEN
- Enter an integer Number
- 37
- 37, is ODD
- Enter an integer Number
- 3456
- 3456, is EVEN
- Enter an integer Number
- 555
- 555, is ODD
- Press any key to continue . . .
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement