1/9
Flashcards covering branching and function commands in Hack VM language.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Branching Commands
Commands that define destinations, jump unconditionally, or jump based on a condition in the Hack VM language. Examples: label, goto, if-goto.
label
Defines a destination within the code for use with goto and if-goto commands. Syntax: label
goto
Jumps execution to the command immediately following the specified label. Syntax: goto
if-goto
Pops a condition from the stack. If true, jumps to the command after
ReLU(x: int)
Returns x if x > 0, otherwise returns 0.
sumInt(n: int)
Calculates the sum of integers from 1 to n.
Function Commands
Commands used to define, call, and return from functions in the Hack VM language. Examples: function, call, return.
function
Declares a function with a given name and number of local variables. Syntax: function
call
Calls a function, specifying the function name and the number of arguments pushed onto the stack. Syntax: call
return
Returns control to the calling function. The callee must push the return value onto the stack before returning. Syntax: return