PROCEDURE/FUNCTION CONTROL
A procedure is a reusable block of code designed to perform a specific task but typically does not return a value to the caller. Procedures are invoked using the CALL
instruction and return control to the caller with the RET
instruction. They help organize code by encapsulating repetitive or modular operations such as input/output handling, data processing, or system interaction. Unlike functions, procedures may rely on side effects like modifying memory or registers rather than returning results through a dedicated register. Procedures often use the stack to manage local variables and save the caller’s state, following calling conventions to ensure program stability and maintainability.
A function is a block of code that performs a specific task and returns a value, typically through a designated register such as AX
, EAX
, or RAX
on x86 architectures. Functions are invoked using the CALL
instruction and return control with RET
. While both functions and procedures are structurally similar in assembly (both use labels, may use the stack, and return with RET
), the key distinction is that functions return a result, whereas procedures typically do not. Functions tend to be more complex, often involving full use of the stack and multiple registers for passing arguments, preserving state, and performing calculations. As such, they usually follow strict calling conventions to maintain compatibility and stability across different parts of a program.

Last updated