[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
Related Courses:
[CSC362 2004S (Rebelsky)]
[CSC362 2010S (Stone)]
Misc:
[SamR]
[GNU Coding Standards]
[Dragon Book]
[Pascal Standards]
Back to The Run-Time Stack. On to Wrapup.
This outline is also available in PDF.
Held: Monday, 5 December 2011
Summary: We consider some of the complexities in dealing with procedure parameters.
Related Pages:
Notes:
Overview:
Variableparameters (aka
pass by reference)
procedure increment (var x: integer); begin x := x + 1; end;
void increment (int *x) { *x = *x + 1; }
x
? It's a parameter, so it should still
be in the stack frame. Let's say it's at %sp(-12)
.
x
in the stack frame?
x
's value (not the pointer value, but the
integer variable)?
IMOV %r0 %sp(-12) # Store the address in r0 IMOV %sp(-16) %r0(0) # Copy the value in that address to a temp.
x
?
IMOV %r0 %sp(-12) IMOV %r0(0) %sp(-20)
increment
, what do we do? E.g.,
var y: integer; begin y := 2; increment(y); end.
type tenints: array[1..10] of integer; function sum(vals: tenints): integer var s: integer; i: integer; begin s := 0; for i := 1 to 10 do begin s := s + vals[i]; end; sum := s; end;
vals[i]
?
Back to The Run-Time Stack. On to Wrapup.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
Related Courses:
[CSC362 2004S (Rebelsky)]
[CSC362 2010S (Stone)]
Misc:
[SamR]
[GNU Coding Standards]
[Dragon Book]
[Pascal Standards]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Wed Dec 7 10:53:46 2011.
The source to the document was last modified on Fri Aug 26 13:03:12 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2011F/Outlines/outline.40.html
.