Firmware engineer Interview Questions
2K
Firmware Engineer interview questions shared by candidates
Write a c functions that takes two bit indices and an int, and reverses the bits in the int between the two indices.
9 Answers↳
Made no mistakes on this question, but had done similar things before
↳
//reverses bit between two indices of a number. #include using namespace std; int main() { unsigned int no=90,i=2,j=6,tmp=0,tmp1=0; tmp=no>>i; cout>1; } cout>1; if(x=i) tmp=tmp|0; else tmp=tmp|0x80000000; } cout< Less
↳
#include main(int arg, char *argv[]) { unsigned char num, hi_indx, lo_indx, mask, num_tmp, mask_c, num_rv, iter,i; num = atoi(argv[1]); hi_indx = atoi(argv[2]); lo_indx = atoi(argv[3]); mask = ((0xFF > (7-hi_indx+lo_indx); mask = (mask << lo_indx); mask_c = ~mask; num_tmp = num & mask_c; printf("%x %d %d %x",num, hi_indx, lo_indx, mask); num_rv = 0x0; iter = hi_indx-lo_indx+1; i = 0; while(i<=iter) { int flg; flg=(num & (1<<(i+lo_indx)))?1:0; if(flg) num_rv=num_rv|(1<<(hi_indx-i)); i++; } num = num_rv | num_tmp; printf("\nnum=%x ",num); } Less

How to swap the values in 2 variables without using a temporary variable.
5 Answers↳
a=a^b b=b^a a=a^b
↳
but it should say swap two integers! because this XOR won't work with float for example Less
↳
This works for floats: a = a+b b = a-b a = a-b But you might overflow on a+b. Less

How many pins in a JTAG cable?
5 Answers↳
25 Pins
↳
Is that even a relevant question ? :)
↳
Why does it matter as long as you know how to use the ICD?

Puzzles 1: You have rope that take 60 min to burn. Speed of burning is not uniform. Example: it doesn't take 30 min to burn half Using two ropes, how would you get 45 min? Answer: First Rope. Burn both ends at same time Second Rope: Burn only one side. when First rope is totally burn, it's been 30 min, now burn the rest of second rope both ends. Which should take additional 15 min. 30 + 15 = 45 min. Puzzle 2: There is a guy in a boat holding a rope that's tight to a Top of pole in the shore. He keep pulling the rope until he reach the shore. What is the speed relationship between amount of rope he pulls, vs horizonal speed? Which speed is higher? Answer: Horizonal speed is faster than the amount of rope he pulls. (Horizonal distance he travel is higher than amount of rope he pulls, by triangle theory where sum of two sides must be greater than 3rd side) Puzzle 3: in Analog Clock, It's exacly 3:00 Clock. What time would the Hour hand, and Min hand would overlap each other?
4 Answers↳
The analog and min hand overlap once each hour so the next overlap after 3:00 would be 3:16 and some change. Sanity check: 16 minutes should be between the 3:00 and 4:00 on the clock, which is true. Math: Hour hand gets an equation like 3 + (1/60)*minutes, since the hour hand starts at 3 and every minute it increases by 1/60th of an hour. The minute hand gets 12*(1/60) * minutes since in 60 minutes it goes around the 12 hours of the clock. So 3+(1/60)x = (12/60)x gives you 180/11 or about 16. Less
↳
1) hour = min / 12 deg 2) min = hour + hour(initial) = hour + 90 deg 1=>2 and solving gives 98.18 deg. Converting back into time format gives 3:16:22. Less
↳
you should keep the same units: Hour hand: starts at 15 min so 15 min + 5 min/hr*t Min hand: 60 min/hr 15 min + 5 min/hr * t = 60 min/hr 15 min = 55 min/hr * t 15/55 = .2727 hr .2727 hr * 60 min/hr = 16.3636 min = 16 min 21.8182 sec Less

Why is a manhole cover round?
4 Answers↳
It's a Microsoft interview question to get you to think.
↳
Hi, is there any technical question? Thanks
↳
Depends on who interviews you. They might write some C code up on a whiteboard and you get to tell them what it does and or what is wrong with it. 2nd Interview is usually to see if you will make a good fit within the environment/culture of the team(s). As long as you can show that you can think or have a basic understanding, all is good. Less

How to invert all the bits in a byte? e.g. 0x55 should be changed to 0xAA.
3 Answers↳
mask=0xffffffff; no^=mask;
↳
But how do you implement ~?
↳
Take 1's complement using ~

write a code to find if a numver is power of 2
2 Answers↳
return (num != 0) && ((num & (num - 1)) == 0);
↳
return((num!=0) && ((num & (-1-num))==0))

Give you a 16 bit binary number. How do you change the 11th and 12th bit to some given number.
3 Answers↳
num = (num & (~(1 << 11 | 1 << 12))) | (given & (1 << 11 | 1 << 12)); Less
↳
num = (num & (~(3 << 12))) | (3 & given << 12 ));
↳
num ^= (Math.Pow(2, 11) + Math.Pow(2, 12))

