-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
layout: post | ||
title: "Stack Machines: Calls" | ||
tags: [] | ||
--- | ||
|
||
# Stack Machines: Calls | ||
|
||
[fundamentals](/2013/08/28/stack-machines-fundamentals.html) << | ||
[rpn-calculator](/2013/12/02/stack-machines-rpn.html) << | ||
[shunting-yard](/2013/12/03/stack-machines-shunting-yard.html) << | ||
[io](/2014/11/29/stack-machines-io.html) << | ||
[jumps](/2014/11/30/stack-machines-jumps.html) << | ||
[conditionals](/2014/12/01/stack-machines-conditionals.html) << | ||
[comments](/2014/12/02/stack-machines-comments.html) << | ||
[**calls**](/2014/12/03/stack-machines-calls.html) | ||
|
||
> Hey I just met you<br /> | ||
> And this is crazy<br /> | ||
> But here's my number<br /> | ||
> So call me maybe<br /> | ||
> | ||
> *— Carly Rae Jepsen* | ||
We have been talking about stack machines (this is a series of posts, go back and read the other posts if you feel lost right now) without ever talking about **calls**. This is rather odd, as most of the time when discussing stacks in programming, we *only* talk about the call stack. | ||
|
||
## Modularity | ||
|
||
A call, sometimes refered to as *procedure call*, *subroutine call* or *function application*, is a means of transfering control to an other sub-program. This implies that we have sub-programs to begin with. | ||
|
||
By breaking programs into procedures the *execution context* or *scope* can be reduced, which makes reasoning about a particular piece of code easier. In other words, you get *modularity*. | ||
|
||
Once a procedure has completed its task, it is able to **return** control back to the caller. | ||
|
||
## Calling conventions | ||
|
||
The anatomy of a procedure call will vary by language, operating system and CPU architecture. There will usually be standard conventions for the instructions involved in performing them, known as **calling conventions**. | ||
|
||
## Summary | ||
|
||
<span style="background-color: yellow;"> | ||
</span> | ||
|
||
--- | ||
|
||
[fundamentals](/2013/08/28/stack-machines-fundamentals.html) << | ||
[rpn-calculator](/2013/12/02/stack-machines-rpn.html) << | ||
[shunting-yard](/2013/12/03/stack-machines-shunting-yard.html) << | ||
[io](/2014/11/29/stack-machines-io.html) << | ||
[jumps](/2014/11/30/stack-machines-jumps.html) << | ||
[conditionals](/2014/12/01/stack-machines-conditionals.html) << | ||
[comments](/2014/12/02/stack-machines-comments.html) << | ||
[**calls**](/2014/12/03/stack-machines-calls.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters