answersLogoWhite

0


Best Answer

With Linux being mostly written in C and normally interfaced via C libraries, I'll give an example from the C point of view, thus I'll refer to functions in place of sub routines.

Using the following C function as an example:

int add(int number1, int number2) { return (number1 + number2); }

Before the add function is called, the values of its arguments are pushed onto the stack by the caller in reverse order (number2 then number1).

When the function is called, it reads the values of number1 and number2 from the stack into CPU registers where the addition is done, leaving the answer in register eaxbefore returning from the function.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How does a subroutine work in Linux?
Write your answer...
Submit
Still have questions?
magnify glass
imp