Embedded
Embedded
Below is a (partial) RIM C program that appropriately sets the display for the given dial
position:
#include "RIMS.h"
void main()
{
while (1) {
switch( A )
{
case 0 : B = 0x77; break; // 0111 0111 (0)
case 1 : B = 0x24; break; // 0010 0100 (1)
case 2 : B = 0x5D; break; // 0101 1101 (2)
//...
case 9 : B = 0x6F; break; // 0110 1111 (9)
default: B = 0x5B; break; // 0101 1011 (E for Error)
}
}
}
i) What B_ outputs should be set to 1 for case 3? List in ascending order separated
by spaces, e.g., B0 B2 ... [5 marks]
ii) To what should B be set for case 3? B = ____; Use uppercase letters for the hex
literal. [5 marks]
b) State and explain the results of the following bitwise operation. [10 marks]
i) 00001111 & 10101010
ii) 00001111 | 10101010
iii) 00001111 ^ 10101010
iv) ~00001111
v) Give a statement that sets B's bits to the opposite of A's bits, so if A is
11110000, B will be 00001111. End with ;