UNIT 7 [cmsc 311]

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:49 PM on 4/2/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

14 Terms

1
New cards

Define a subroutine.

A subroutine is a reusable sequence of instructions that performs a specific task and can be called from different parts of a program.

2
New cards

Difference between caller and callee.

caller=program that contains call instruction / callee=subroutine that contains the return instruction

3
New cards

Compare JSR and JSRR.

  • JSR uses PC-relative addressing to jump to a subroutine, while JSRR uses a base register to determine the target address.

  • Both instructions store the return address in R7 so the program can return after the subroutine finishes.

4
New cards

HOW JSR / JSRR WORK

  • Both:

    • save return address → R7

    • jump to subroutine

  • JSR:

    • uses offset from PC

  • JSRR:

    • uses register value

5
New cards

What is RET and why is it “fake”?

RET is a pseudo-instruction that returns from a subroutine by jumping to the address stored in R7. It is considered “fake” because it is actually translated into JMP R7.

6
New cards

Define and contrast caller-save and callee-save

  • caller = program saves & restores registers

  • callee = subroutine saves & restores the registers

  • difference = who saves register

7
New cards

What is a stack?

a data structure that follows Last-In, First-Out (LIFO), meaning the last value added is the first one removed.

8
New cards

What is the stack pointer?

The stack pointer is a register (R6 in LC-3) that holds the address of the top of the stack and is used to manage push and pop operations.

9
New cards

Where is the stack pointer stored?

The stack pointer is stored in register R6.

10
New cards

Why doesn’t the stack physically move?

The stack does not physically move because only the stack pointer changes. This is efficient because it avoids copying data and allows fast push and pop operations.

11
New cards

How does push work?

decreases the stack pointer and stores a value at the new top of the stack

12
New cards

How does pop work?

Pop retrieves the value at the top of the stack and then increases the stack pointer.

13
New cards

Define stack overflow and underflow.

  • overflow: stack pointer so small it’s now in same range as memory or data of the program

  • underflow: when the stack pointer is larger than the memory location where the stack starts

14
New cards

How are strings stored?

as ASCII characters in consecutive memory locations and are terminated by a null character (x0000).

Explore top flashcards

flashcards
Cô Yến 5/12/2024
22
Updated 480d ago
0.0(0)
flashcards
EXAM 2 - part 6
22
Updated 250d ago
0.0(0)
flashcards
Einheit 1 Freunde
75
Updated 229d ago
0.0(0)
flashcards
Biology Honors Evolution
51
Updated 1096d ago
0.0(0)
flashcards
Matiekos egzas
73
Updated 819d ago
0.0(0)
flashcards
Livy 2.10 Vocab
20
Updated 1215d ago
0.0(0)
flashcards
Cô Yến 5/12/2024
22
Updated 480d ago
0.0(0)
flashcards
EXAM 2 - part 6
22
Updated 250d ago
0.0(0)
flashcards
Einheit 1 Freunde
75
Updated 229d ago
0.0(0)
flashcards
Biology Honors Evolution
51
Updated 1096d ago
0.0(0)
flashcards
Matiekos egzas
73
Updated 819d ago
0.0(0)
flashcards
Livy 2.10 Vocab
20
Updated 1215d ago
0.0(0)