C12 Embedded systems in MicroPython and C · Practice
C for small machines: fixed-width types, bits and volatile
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
0 solved
0 in a row
0 of 11 kinds solid
Check
Read the 4-bit field at bit 4 of BEEF. What value is it, in hex?
Check
A register byte holds B9. What does it hold after x &= ~(1u << 0);, in hex?
Check
A uint8_t holds 250. What does it hold after adding 60?
Check
An array of 64 elements, each 1 byte(s) wide (uint8_t, uint16_t or uint32_t): how many bytes of RAM does it use?
Check
What's the largest value a 5-bit unsigned field can hold?
Check
X is 48879. Print the 4-bit field that starts at bit S (4), then print X with that field replaced by 12 and every other bit unchanged.
C on the course's RISC-V board (10 MHz, no floating point). #include "board.h" for the registers; print(x) shows a number. Tab indents; press Esc and then Tab to move on.
Check
A register holds 0E97. A field of 4 bits starts at bit 4.
(a)
What is the field's value?
(b)
What does the register hold after the field is cleared?
Check
200 and 100 are added in 8-bit variables.
(a)
What does a uint8_t hold?
(b)
What does the same bit pattern mean as an int8_t?
Check
A5 after clearing bit 2, in hex?
Check
uint8_t 240 plus 20?
Check
Largest value in 8 unsigned bits?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C12