Computer Systems eXercises #4

## Bits and Bytes - Solutions

```
1.
1. true and true = true
2. true or false = true
3. (true and not true) or false = false or false = false
4. not(true and true) and (true and false) = not true and false = false and false = false
5. true and (not true or true) or (not false or not true) and false
= true and true or true and false
= true or false = true

2.
1. 10111111 and 10101010 = 10101010
2. 10111111 or 11110000 = 11111111
3.  (10111111 and not 10101010) or 11110000
= (10111111 and 01010101) or 11110000
= 00010101 or 11110000
= 11110101
4. not(10111111 and 10101010) and (10111111 and 111100000)
= not(10101010) and 10111111
= 01010101 and 10111111
= 00010101
5. 10111111 and (not 10111111 or 10101010) or (not 11110000 or not 10101010) and 11110000
= 10111111 and (01000000 or 10101010) or (00001111 or 01010101) and 11110000
= 10111111 and 11101010 or 01011111 and 11110000
= 10101010 or 01010000
= 11111010

3.
1.  9063 in bin = 0010 0011 0110 0111
flip=	1101 1100 1001 1000
+1=	1101 1100 1001 1001
2.	shl3=	1110 0100 1100 1000
=	-25800 which is not equal to the expected -72504 because as part of the shl
process, bits 'fell off'
3. 	shr5=	1101 1100 1001 1001
=	56473 which is not -566 as expected, due to the movement of the sign bit into
the number

4. should be ZERO as the not should flip the word, and will cancel all set bits

4.
1. some interupts are more important than others
2. The interupt Vector Table contains a list of pointers to error handling routines that the
CPU uses to 'look up' solutions to problems indicated by the relevant interupt
3. the task the CPU was first working on is PUSHED onto the stack, the CPU looks up the
incoming interupt in the Interupt Vector Table, loads the relevant code to deal with the
interupt *NEW INTERUPT* the current interupt is PUSHED (uncompleted) onto the stack and the
CPU looks up the new interupt in the Interupt vector table, loads the appropriate instructions,
executes them, then POPS the previously unclompleted interrupt off the stack, finishes it's
execution, then POPS the original task of the stack and continues working with it.

5.
1. not 1111 1111 = 0000 0000
2. 0001 1011 or 0010 1101 = 0011 1111
3. 1111 1111 and 0000 0011 = 0000 0011

6.
1. to isolate just the month, you could SHL7 and then SHR14
2. if 1100 0100 0000 0000 and date = 1100 0100 0000 0000
then it is 1998  (as 98 = 1100010)

```

wonko@wonko.info