04b-SubroutinesStack

04b-SubroutinesStack - Subroutines and Stack Usage on the...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Subroutines and Stack Usage on the MicroBlaze ECE 2534 Microprocessor System Design 1 icroBlaze subroutines MicroBlaze subroutines Same idea as a C/C++ function Theres no call instruction Instead, branch and link Example: MAIN_PROG: . . . rlid 15 MY SUB brlid r15, MY_SUB nop . . . . . MY_SUB: <sub. code goes here> 2 Packet 4b rtsd r15, 8 nop AIN PROG MAIN_PROG: . . . rlid 15, MY SUB This puts the ddress of the brlid brlid r15, MY_SUB nop . . . address of the brlid instruction into r15. Execution transfers MY_SUB: <sub. code goes here> to MY_SUB. his transfers rtsd r15, 8 nop This transfers execution to r15 + 8, = the 2 nd instruction fter the brlid after the brlid. A delay instruction allows the instruction following it to 3 Packet 4b execute before the branch is taken ther instructions are available Other instructions are available To invoke a subroutine: brld rD, rB brald rD, rB brlid rD, IMM bralid rD, IMM link: rD PC ( bsolute if ( absolute ) PC offset else PC PC + offset To return from a subroutine: rtsd rA, IMM 4 Packet 4b PC rA + sext(IMM) Allow following instruction to complete execution sues with subroutine linkage Issues with subroutine linkage The convention is to use r15...
View Full Document

This note was uploaded on 02/07/2011 for the course ECE 2534 taught by Professor Abbott during the Fall '10 term at Virginia Tech.

Page1 / 12

04b-SubroutinesStack - Subroutines and Stack Usage on the...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online