MSP430 Microcontroller Questions and Answers – Functions and Subroutine

This set of MSP430 Microcontroller Quiz focuses on “Functions and Subroutine”.

1. Which instruction is used to call functions?
a) MOV
b) GO
c) CALL
d) All of the mentioned
View Answer

Answer: c
Explanation: CALL instruction is used for going to a particular address in MSP430. It actually causes the pointer to jump at a particular address and push the current address of the PC to the stack.

2. ret instruction is used for _________
a) determining the end of the program
b) for returning back from the subroutine to the main program
c) for transferring data from one place to another
d) none of the mentioned
View Answer

Answer: b
Explanation: Ret instruction is basically used for returning back from a subroutine. It actually pops the top address from the stack and moves that address to its PC, so that it now returns to the main program and continue the execution normally.

3. According to conventions being followed, R12 to R15 are used for _________
a) parameter passing
b) preserved for call
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: According to the conventions, R12 to R15 are used for parameter passing and hence are not preserved for the call.
advertisement
advertisement

4. We can store the temporary results across a call instruction with the help of which of the following registers
a) R1-R4
b) R4-R11
c) R12-R15
d) All of the mentioned
View Answer

Answer: b
Explanation: Temporary results are stored by the registers R4-R11.

5. Can we allocate variables on the stack?
a) yes
b) no
c) cant be said
d) depends on the conditions
View Answer

Answer: a
Explanation: Yes, we can allocate the variables on the stack, it is a very effective way of storing the variables.

6. Which registers are reserved for passing the parameters to a subroutine and then returning the final result?
a) R1-R4
b) R4-R11
c) R12-R15
d) All of the mentioned
View Answer

Answer: c
Explanation: Originally, R12-R15 registers are reserved for passing the parameters to a subroutine and then returning the final result.

7. What actually is the order of stack frame for a parameter to pass to a subroutine?
a) parameter passed to a subroutine
b) return address
c) saved copies of registers(R4-R11)
d) all of the mentioned
View Answer

Answer: d
Explanation: All the steps i.e. parameter passed to a subroutine, return address, saved copies of registers(R4-R11), local variables in subroutines are required for passing a parameter to a subroutine.
advertisement

8. When any subroutine is called, then the first value of stack will be
a) value of PC
b) the return address
c) none of the mentioned
d) both are one and the same things
View Answer

Answer: d
Explanation: When any subroutine is called then the first place of the stack will be filled with the return address, or the address of the PC so that the pointer may return back to its appropriate place after the return instruction of the subroutine.

9. Which of the following instruction/s is/are used to return back to the main program after the subroutine is completed?
a) ret
b) reti
c) ret and reti
d) none of the mentioned
View Answer

Answer: c
Explanation: For returning back from the subroutine, both ret and reti can be used, the main difference between the two is that reti just resets the interrupt flag before the return, so that the interrupt can occur again.
advertisement

10. Is the approach of making subroutines effective or not?
a) yes
b) no
c) cant be said
d) depends on the conditions
View Answer

Answer: a
Explanation: The approach of making subroutine is indeed very effective, as with its help we don’t need to retrace/write a particular set of codes again and again. It makes our approach modular.

Sanfoundry Global Education & Learning Series – Microcontroller.

To practice all areas of Microcontroller for Quizzes, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.