• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/28

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

28 Cards in this Set

  • Front
  • Back

What are some advantages of high-level Languages?

-give symbolic names to values


-provides abstraction of underlying hardware


-provides expressiveness


-enhances readability


-safeguards against bugs

What are two different strategies in translating high-level languages?

-interpretation


-compilation

What are advantages to interpretation?

-easy to debug, make changes


-one command per line

What are advantages to compilation?

-translate statements into machine language


-harder to debug

What are two ways of passing parameters to a function?

call-by-value - caller passes value to function and function holds copy - caller does not see changes




call-by-reference: caller passes address of a variable to the function - caller and function operate on same value

What is the header structure for main?

int main ( int argc, char * argv[] )




argc is no. of arguments including name of program


argv[] is listing of all the arguments

What is stored in a symbol table?

stores name, type, location, scope

What is R5?

frame pointer -holds address of the base of current frame


stack grows downward so offsets are <= 0

What is R6?

R6 points to top of stack

What is R4?

global data pointer - grows upwards after instructions - points to base

Why are global variables initialized but function variables not?

static variables are initialized at compile-time, since their address is known and fixed. Initializing them to 0 does not incur a runtime cost.


automatic variables can have different addresses for different calls and would have to be initialized at runtime each time the function is called, incurring a runtime cost that may not be needed. If you do need that initialization, then request it.

What is an activation record?

information about each function including arguments, local variables, return address stored on run-time stack

What happens in calling a function from the point of view of the caller?

copy values into arguments


call function




(after function complete)




get result from stack

What happens in calling a function from the point of view of the called function?

set up environment


execute code


put result in activation record


pop activation record from stack


return

Which register points to the beginning of the activation record's local variable store?

Frame pointer R5

What happens when a new function is called?

it's activation record is pushed onto the stack

What happens when a function returns?

its activation record is popped off the stack

In the activation record, what comes before the local variables?

arguments starting from last argument


then return value


then return address


then dynamic link

What is a dynamic link?

-caller's frame pointer


-used to pop this activation record from the stck

What is the return address?

pointer to NEXT INSTRUCTION in calling function


convenient location to store R7 in case another function is called

Is the return value allocated if the function does not return a value?

YES

What does JSR do?

Jumps to location AND saves current PC (next instruction) in R7

What is linking?

saving the return address



What is determined by bit 11 of JSR?

if 1 - target address = (PC + Sext(IR[10:0]))


if 0 - target address = contents of register IR[8:6]


JSRR in book

What is the sequence for returning from a function?

copy return value


pop local variables


pop dynamic link


pop return address

What does the RET command do?

JMP R7

What happens when the caller resumes?

load return value


perform assignment


pop return value


pop arguments

summary of LC-3 function call implementation?

caller pushes arguments (last to first)


caller invokes subroutine with JSR


callee allocates return value, pushes R7 & R5


callee allocates space for local variables


callee executes function code


callee stores results into return value slot


callee pops local vars, R5, R7


caller loads return value and pops argument


caller resumes computation