COS10004 Lecture Notes - Lecture 11: Goto, Javacc, Subroutine
Document Summary
- execute instructions starting at label xyz i. e. subprograms. - jump back to the next instruction after the call. In fact this return statement is optional (in these languages) Like goto, the call and return instructions take 2 cpu cycles. The pc is incremented during first cycle to point to next address in memory. The pc is modified in the 2nd cycle. Like goto, call gets 11 address bits from the instruction, the other 2 from the pclath register (not shown here) If the subroutine is in a different page of code then need to set up. The microchip stack is 8 deep, so. Maximum depth of nested calls is 8. Maybe more if nested interrupts are programmed. (and less one for on-chip debugger if used) Already full a fatal error: program stops. Easy if it is a byte: var =xyz(); // some code to calculate r return r;