Back to the 2025 paper

Module 3: Instruction Set and Programming

20257m

Explain subroutine instructions and stack operations in 8051.

Worked SolutionAI Assisted

Subroutine Instructions & Stack Operations

Instructions: LCALL addr16 (3B, pushes PC+3, jumps 64K), ACALL addr11 (2B, page within 2K), RET (pops PC), RETI (pops + clears interrupt). LCALL vs ACALL tradeoff size vs range.

Stack Operations: Stack located in internal RAM, SP=07H reset, grows up. PUSH direct → SP++, [SP]←src; POP direct → dst←[SP], SP--. Used for saving ACC/PSW/B before subroutine/ISR. Example preservation:

PUSH ACC
PUSH PSW
; subroutine
POP PSW
POP ACC
RET

Overflow if SP > 7FH collides SFR region, so initialise MOV SP,#60H. Nesting limited by RAM.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.