Subroutines
Subroutines in ASM2 are similar to functions but are typically used for smaller, reusable tasks within a larger program. They might not return a value themselves but can modify existing variables or registers.
Naming and Usage Convention:
CamelCase with Dot Prefix: Subroutine names must use camelCase and start with a
.
.No Initial Numbers: Cannot start with a number.
Not Solely Numeric: Cannot be just a number.
No Special Characters: Cannot contain special characters.
Usage:
CALL .subroutineName
General Structure:
Example:
Key Points:
Specialized Use: For specific, often-repeated tasks within larger functions.
No Direct Return Value: Typically modifies existing variables or registers instead of returning values.
Enhanced Program Structure: Contributes to a clearer, more organized program structure.
CALL
Instruction: Used to invoke the subroutine from a function or main program.
Last updated