BME303_lecture14 - BME303 Intro. to Computing Subroutines A...

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

View Full Document Right Arrow Icon
BME303 Intro. to Computing Subroutines A subroutine is a program fragment that: – lives in user space – performs a well-defined task – is invoked (called) by another user program – returns control to the calling program when finished Like a service routine, but not part of the OS – not concerned with protecting hardware resources – no special privilege required Reasons for subroutines: – reuse useful (and debugged!) code without having to keep typing it in – divide task among multiple programmers – use vendor-supplied library of useful routines
Background image of page 1

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

View Full DocumentRight Arrow Icon
BME303 Intro. to Computing JSR Instruction Jumps to a location (like a branch but unconditional), and saves current PC (addr of next instruction) in R7. – saving the return address is called “linking” – target address is PC-relative (PC + Sext(IR[10:0])) – bit 11 specifies addressing mode • if =1, PC-relative: target address = PC + Sext(IR[10:0]) • if =0, register: target address = contents of register IR[8:6]
Background image of page 2
BME303 Intro. to Computing JSR NOTE: PC has already been incremented during instruction fetch stage.
Background image of page 3

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

View Full DocumentRight Arrow Icon
JSRR Instruction Just like JSR, except Register addressing mode. –target address is Base Register
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 16

BME303_lecture14 - BME303 Intro. to Computing Subroutines A...

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

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