#include <stdio.h> #include <stdint.h> uint32_t set_baud_rate(uint32_t reg, uint8_t baud) { // Your code here uint32_t mask; mask = baud; mask = mask << 8; // move mask into place reg = (reg & 0xFFFFF0FF); // clear the hole reg = (reg | mask); // insert the mask return reg; } int main() { uint32_t reg; uint8_t baud; scanf("%u %hhu", ®, &baud); printf("%u", set_baud_rate(reg, baud)); return 0; }
move the mask into place
create a hole in the register, punch out current baud rate
insert the new baud rate
Test Cases
Test Results
Input
0 10
Expected Output
2560