COMP1860 Lecture 3.1 Virtual Machines: Control

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/9

flashcard set

Earn XP

Description and Tags

Flashcards covering branching and function commands in Hack VM language.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

Branching Commands

Commands that define destinations, jump unconditionally, or jump based on a condition in the Hack VM language. Examples: label, goto, if-goto.

2
New cards

label

Defines a destination within the code for use with goto and if-goto commands. Syntax: label

3
New cards

goto

Jumps execution to the command immediately following the specified label. Syntax: goto

4
New cards

if-goto

Pops a condition from the stack. If true, jumps to the command after

5
New cards

ReLU(x: int)

Returns x if x > 0, otherwise returns 0.

6
New cards

sumInt(n: int)

Calculates the sum of integers from 1 to n.

7
New cards

Function Commands

Commands used to define, call, and return from functions in the Hack VM language. Examples: function, call, return.

8
New cards

function

Declares a function with a given name and number of local variables. Syntax: function

9
New cards

call

Calls a function, specifying the function name and the number of arguments pushed onto the stack. Syntax: call . The caller must push values onto the stack first.

10
New cards

return

Returns control to the calling function. The callee must push the return value onto the stack before returning. Syntax: return