Midterm (GPT) Flashcards
What is systems software?
It is a type of software that manages and operates computer hardware.
What is a compiler? An interpreter? What is the difference?
A compiler translates high-level code into machine code, while an interpreter executes high-level code directly.
What is an assembler?
It is a type of software that converts assembly language into machine code.
What does a linker do? What does a loader do?
A linker combines object files into an executable file, while a loader loads an executable file into memory for execution.
What does a compiler do (overall)?
It translates high-level code into machine code.
What role does a VM play in systems software?
A VM provides a layer of abstraction between hardware and software, allowing software to run on different hardware architectures.
What is an object file? What is its format?
An object file contains compiled code and data in a format that can be linked to create an executable file.
What is the ISA?
It is the instruction set architecture that defines the set of instructions that a processor can execute.
When does the program counter get incremented in a VM’s cycle?
The program counter is incremented after each instruction is executed.
What does a jump instruction do in terms of how it affects the PC?
A jump instruction changes the value of the program counter to a new address, causing the VM to execute instructions at that address.
What are the details (e.g., opcodes) for the Tiny VM?
Not specified in the text.
How can one tell if an ISA has enough instructions?
It depends on the needs of the software that will be executed on the processor.
Why does an ISA need a HLT (halt) instruction?
It provides a way for a program to exit cleanly and return control to the operating system.
What happens if there is no halt instruction in a program?
The program may continue to execute indefinitely or crash.
How would an if-then-else statement in a high-level language get translated into machine code (in terms of jump instructions)?
It would be translated into conditional jump instructions based on the condition being tested.
How would a while loop be translated into machine instructions (in terms of what jump instructions and needed)?
It would be translated into a conditional jump instruction at the end of the loop, which jumps back to the beginning of the loop if the condition is true.
What is the memory hierarchy? Why is it important?
It is the hierarchy of different types of memory, such as cache, RAM, and disk, with faster and smaller memory at the top and slower and larger memory at the bottom. It is important for optimizing the performance and efficiency of computer systems.
What are the advantages of assembly language over machine code?
Assembly language is easier to read and write than machine code. Assembly language allows for the use of symbolic labels, making it easier to understand what specific instructions do. Assembly language can also use comments to help clarify the code.
Why are subroutines important?
Subroutines allow for code reuse and can make programs more efficient by reducing the amount of duplicated code. Subroutines also help to make code more modular and easier to understand.
What capabilities does a programming language need from a VM to support subroutines?
A programming language needs the ability to define and call subroutines, as well as the ability to pass arguments to and return values from subroutines. The VM must also provide a way to manage the memory and stack for each subroutine.
What features in a VM help support subroutines?
A VM needs to support a stack to store information for each subroutine call, as well as a way to store and retrieve values from memory. The VM should also support a call instruction and a return instruction to jump to and from subroutines.
What is static scoping? Why is it useful?
Static scoping is a way of determining the scope of a variable at compile time. It is useful because it allows a programmer to reason about the behavior of their program before it is executed and to prevent bugs caused by name clashes or incorrect variable scoping.
What is dynamic scoping?
Dynamic scoping is a way of determining the scope of a variable at runtime, based on the current execution context.
When is dynamic scoping useful?
Dynamic scoping is useful when a program needs to access variables that are not in its immediate scope, but in a parent or ancestor scope.
What is the difference between a static property and a dynamic property (in general terms)?
A static property is one that is determined at compile time and does not change during program execution. A dynamic property is one that is determined at runtime and can change during program execution.
What is block structure in a programming language?
Block structure is a way of organizing code into blocks, which can have their own scopes and variables.
What are the advantages of block structure?
Block structure allows for more modular and organized code. It also helps prevent naming conflicts by limiting the scope of variables to their specific blocks.
Why should a language support recursion?
Recursion is a powerful programming technique that allows functions or procedures to call themselves. It is useful for solving problems that have a recursive nature, such as tree traversal or searching algorithms.
Why is it useful to have recursion to write a context-free parser?
Recursion is useful for parsing context-free grammars because it allows the parser to handle nested constructs without having to explicitly define each possible combination of constructs.
What data structure in a VM or computer is necessary for supporting recursive procedures?
A stack is necessary for supporting recursive procedures because it allows the program to keep track of the current execution context and to return to previous contexts when a function or procedure call is completed.
What is an AR?
An AR (Activation Record) is a data structure used by the VM to store information about a procedure or function call, including the return address, local variables, and arguments.
What information is stored in an AR?
An AR typically stores the return address, local variables, arguments, and any other necessary information for a specific function or procedure call.