Open main menu

CDOT Wiki β

Changes

6502 Jumps, Branches, and Procedures

577 bytes added, 16:16, 23 September 2021
Procedures
To return from the procedure, the RTS (ReTurn from Subroutine) instruction loads the PC from the stack, causing execution to continue at the instruction immediately after the JSR.
 
Note that in assembly language, return values can be passed back to the calling function in registers or through stored values. In practical terms, the way that values are returned will depend on the type of data - for example, strings will generally be passed back in memory, while small integers or pointers can be passed in registers.
 
Note also that at the machine language level, there is no distinction between functions, methods, subroutines, and procedures - these distinctions apply only at the source code level and disappear during compilation to machine language.