CSC 311: COMPUTER ORGANIZATION AND ARCHITECTURE
Lab 8 – Due 04/21/2022, 11:59 PM
Write functions to compute a subset, find member, union, and intersection of sets. Follow the steps
elow:
1. Read two integers from the user.
2. Suppose one of the integers is XXXXXXXXXXThe binary equivalent of this integer stored in a
egister will be XXXXXXXXXX XXXXXXXXXX. This data should be regarded as bit
strings representing subsets of the set {1, 2, … 32}. If the bit string has a 1 in position i, then
element i is included in the subset.
Therefore, the string: XXXXXXXXXX XXXXXXXXXX co
esponds to the set: {2, 3,
4, 8, 10, 23, 24, 25, 28, 32}.
3. Print out members of the set from smaller to larger. You can do a loop from 1 to 32. Load a
masking bit pattern that co
esponded to the position number of the loop counter (0x XXXXXXXXXX
for 1). Isolate the bit in the operand by using the AND operation. If the result of the AND is not
0 then the loop counter is in the set and should be displayed. Increment the counter and shift the
masking bit pattern to the left.
4. Read a number from the user. Determine if that element is a member of the given sets.
5. Determine the union of two sets.
6. Determine the intersection of two sets.
7. Implement a loop back to the main function. See the prompts below:
“Enter the first number:”
“Enter the second number:”
“Members of Set 1:”
“Members of Set 2:”
“Enter an element to find:”
“It is a membe
not a member of set 1”
“It is a membe
not a member of set 2”
“Union of the sets:”
“Intersection of the sets:”
“Do you want to compute set functions again?”
8. Test the program using the following data:
Enter the first number: 99999
Enter the second number: 111445
Members of set 1: XXXXXXXXXX16 17
Members of set 2: XXXXXXXXXX16 17
Enter an element to find: 7
It is not a member of set 1
It is a member of set 2
Union of the sets: XXXXXXXXXX XXXXXXXXXX
Intersection of the sets: XXXXXXXXXX
Submission guidelines:
You need to submit your Lab8.s file and a screenshot of the Run I/O display with input values:
Enter the first number: XXXXXXXXXX
Enter the second number: XXXXXXXXXX
Enter an element to find: 17
Submit a single .zip file with name Lab8_firstname_lastname.zip (Your .zip file should contain Lab8.s
and Screenshot).