lab3 function call

50 views
Skip to first unread message

Simon

unread,
Mar 10, 2014, 3:06:39 PM3/10/14
to proglang-c...@googlegroups.com
Hello!

How exactly is the function call / function def to be compiled? I find the book very hard to follow here (otherwise easy to follow!). Right now I'm putting args on stack before invoking the function and then putting them in storage inside the function.. I'm abit fuzzy on what's global and local

Aarne Ranta

unread,
Mar 10, 2014, 4:07:16 PM3/10/14
to proglang-c...@googlegroups.com
Hello Simon,

When calling a function:

- compile the arguments and leave them on the stack
- call the function, which expects to find the arguments on the stack

When compiling a function definition:

- reserve the first addresses of variable storage for the arguments
- store the locals after the arguments

In the book, p. 108, this is expressed by saying

- for i = 1,..,m: extend(xi,ti)  -- the arguments
- for i = 1,...,n: compile(si)  -- this includes the locals declared in si

Regards

  Aarne.

Simon

unread,
Mar 10, 2014, 4:19:54 PM3/10/14
to proglang-c...@googlegroups.com
Thanks, helpful!

Also.. found this just now.
Reply all
Reply to author
Forward
0 new messages