26.06.2015 Views

Chapter 4: The Instruction Set Architecture - 10/31/2013 02:13:31 ...

Chapter 4: The Instruction Set Architecture - 10/31/2013 02:13:31 ...

Chapter 4: The Instruction Set Architecture - 10/31/2013 02:13:31 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4-26<br />

Stack<br />

Linkage<br />

Example<br />

• A C program<br />

illustrates nested<br />

function calls.<br />

Line<br />

No.<br />

00<br />

01<br />

<strong>02</strong><br />

03<br />

04<br />

05<br />

06<br />

07<br />

08<br />

09<br />

<strong>10</strong><br />

11<br />

12<br />

<strong>13</strong><br />

14<br />

15<br />

16<br />

17<br />

18<br />

19<br />

20<br />

21<br />

<strong>Chapter</strong> 4: <strong>The</strong> <strong>Instruction</strong> <strong>Set</strong> <strong>Architecture</strong><br />

/* C program showing nested subroutine calls */<br />

main()<br />

{<br />

int w, z; /* Local variables */<br />

w = func_1(1,2); /* Call subroutine func_1 */<br />

z = func_2(<strong>10</strong>); /* Call subroutine func_2 */<br />

} /* End of main routine */<br />

int func_1(x,y) /* Compute x * x + y */<br />

int x, y; /* Parameters passed to func_1 */<br />

{<br />

int i, j; /* Local variables */<br />

i = x * x;<br />

j = i + y;<br />

return(j); /* Return j to calling routine */<br />

}<br />

int func_2(a) /* Compute a * a + a + 5 */<br />

int a; /* Parameter passed to func_2 */<br />

{<br />

int m, n; /* Local variables */<br />

n = a + 5;<br />

m = func_1(a,n);<br />

return(m); /* Return m to calling routine */<br />

}<br />

Principles of Computer <strong>Architecture</strong> by M. Murdocca and V. Heuring<br />

© 1999 M. Murdocca and V. Heuring

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!