COMP1860 Lecture 2.2 Virtual Machines: Stack

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
GameKnowt Play
New
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/23

flashcard set

Earn XP

Description and Tags

Flashcards covering key vocabulary and concepts related to virtual machines, stack architecture, and the Hack VM language, based on lecture notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

24 Terms

1
New cards

Virtual Machine Abstraction

An abstraction layer that allows code to run on different hardware platforms by providing an intermediary layer between the code and the hardware.

2
New cards

Hack VM Language

A low-level language used for virtual machines, utilizing arithmetic and logical operations to manipulate data on a stack-based architecture.

3
New cards

Stack Pointer (sp)

A pointer that indicates the next available position on the stack, not the top element, used for managing data flow in stack-based operations.

4
New cards

Push Operation

A fundamental stack operation that adds an element to the top of the stack.

5
New cards

Pop Operation

A fundamental stack operation that removes the top element from the stack.

6
New cards

Stack Arithmetic

Performing arithmetic operations by popping operands from the stack, evaluating the result, and pushing the result back onto the stack.

7
New cards

One tier compilation

High level programming language is compiled directly into machine level instructions.

Pros
1. Generates efficient code
2. Can take full advantage of hardware


Cons
1. Requires one compiler per target platform
2. Porting and maintaining software is time consuming

8
New cards

Two-Tier Compilation

High-level language is first compiled to an intermediate code (VM commands/bytecode), and then a VM translator converts this to machine code.

Pros
1. Compile once, run everywhere
2. Maximum portability


Cons
1. Requires VM translator per target platform
2. Generates less less efficient machine code

9
New cards

Memory Segments

Designated areas in memory used to store different types of data, such as constants, static variables, local variables, arguments, and pointers.

10
New cards

Constant Segment

A memory segment used to push constant values onto the stack; pop operations are not permitted from this segment.

11
New cards

Local Segment

A memory segment used to store a function's local variables, typically used for function calls.

12
New cards

Argument Segment

A memory segment used to store a function's arguments, commonly used for function calls.

13
New cards

This Segment

A variable memory segment that starts at pointer[0] and is commonly used to point to objects or arrays.

this i means: "the i-th element of the array starting at the address held in this"

14
New cards

That Segment

A variable memory segment that starts at pointer[1] and is commonly used to point to objects or arrays.

that i means: "the i-th element of the array starting at the address held in that"

15
New cards

Pointer Segment

The starting point for 'this' and 'that' memory segments.

16
New cards

Temp Segment

A memory segment containing eight temporary variables for short-term storage.

17
New cards

VM Emulator

A software tool that simulates the execution of virtual machine code, allowing developers to test and debug their programs.

18
New cards

LCL (Local)

Base address of local segment.

19
New cards

ARG (Argument)

Base address of the argument segment.

20
New cards

THIS

Base address of this segment, used for objects/arrays

21
New cards

THAT

Base address of that segment, used for objects/arrays

22
New cards

True/false

True = -1

False = 0

23
New cards

Arithmetic and logical operations

knowt flashcard image
24
New cards

Difference between static and temp

  • Static variables retain their value between function calls and are stored in the data segment (have a fixed memory location).

  • Temp (temporary) variables are typically stored in registers or stack, used only during a short computation, and are not preserved after use (only exist during a specific function).