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-25<br />

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

Subroutine Linkage – Stack<br />

• Subroutine linkage with a stack passes parameters on a stack.<br />

! Calling routine<br />

.<br />

%sp<br />

.equ %r14<br />

addcc %sp, -4, %sp<br />

st %r1, %sp<br />

addcc %sp, -4, %sp<br />

st %r2, %sp<br />

call add_3<br />

ld %sp, %r3<br />

addcc %sp, 4, %sp<br />

.<br />

! Called routine<br />

! Arguments are on stack.<br />

! %sp[0] ← %sp[0] + %sp[4]<br />

%sp<br />

add_3:<br />

.equ %r14<br />

ld %sp, %r8<br />

addcc %sp, 4, %sp<br />

ld %sp, %r9<br />

addcc<br />

st<br />

%r8, %r9, %r<strong>10</strong><br />

%r<strong>10</strong>, %sp<br />

jmpl %r15 + 4, %r0<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!