Midterm Flashcards
… enables running programs on a computer
Systems Software
Compilers, interpreters, assemblers, linkers, loaders, and OS are examples of…
Systems Software
Translates a (high-level) language into a form that can be (more easily) executed by a computer.
Compiler
It allows several abstraction mechanisms, to help programs be as close to the language of the domain as possible, such as subroutines and data types, perhaps allowing for new control mechanisms.
What it means for a programming language to be “high-level”
Executes a programming language direct without translating it into some other language first. However, it may do some translation into an internal format (e.g., a virtual machine language)
Interpreter
What are some examples of languages with interpreters?
Python, Java (to some extent)
Only compiles programs into machine code as needed, and interprets seldom used code.
just-in-time compiler
Translates a low-level language that is close to machine code into machine code. Uses human-readable names for instructions and macros. Typically there is a one-to-one ratio to the translated machine code
Assembler
combines parts of a program into a single executable file, resolving external names (e.g., for library functions)
Linker
Why is a linker needed in C?
Because C programs can use external functions (e.g., libraries)
Puts a program in a computer’s memory turning relative addresses within a program into (more) absolute addresses
Loader
Allows the state of a program’s execution to be investigated, typically by displaying the computer’s state and allowing execution to be traced or stopped.
Debugger
A program that manages a computer’s resources. It provides abstractions of the various resources (e.g., files and directories), security, and helps use resources efficiently
Operating System
What are some examples of interpreted programming languages?
Python, Lisp, Scheme, Java (to some extent)
What are the advantages of using a VM (vs. direct execution)?
Faster: as can do just-in-time compilation, some simple optimization…
More portable: only the VM needs to be rewritten for portability
Flexibility: the VM can support better linking and debugging
What is a computer’s memory like (as a data structure)?
A (big) one-dimensional array
Holds the compiled code of a program module. It can be linked into a complete program.
Object File
What information must be stored in an object file?
- code (compiled, sometimes called the “text” of the program)
- data space (and initial values for some data –static data
and just space reservations for uninitialized data)
- metadata about the file (sizes of text and data, header)
- symbols for linkage to other modules (exported, imported)
If you were designing a format for object files, what information would you put first?
Metadata
What are the four sections of an object file?
Header, text section, data section, symbol table
What are the main parts of a computer CPU?
Memory, ALU, PC, registers
A register that holds the address of the next instruction to be executed
PC (Program Counter)
Holds the address to be read or written to in the memory
MAR (Memory Address Register)
Can the program be altered once it is in MEMORY?
Yes, that is needed for linking/loading and is also a security problem!
Stores data that is being sent to the memory or received from it. (This could be either code or data.)
MDR (Memory Data Register)
Executes arithmetic and logical instructions.
ALU
It communicates with the Control unit to tell the ALU and other parts of the CPU what to do, based on the op-code from the IR.
Decoder
The user-visible register in tiny machine.
ACCUM (Accumulator)
The design of a computer CPU (or a VM)
ISA (Instruction Set Architecture)
What are the steps of the instruction cycle?
- Fetch
- Execute
What happens during the fetch step of the instruction cycle?
IR <- MEMORY[PC]
What happens during the execute step of the instruction cycle?
- Advance the PC
- Decode and execute instruction in IR
When does the program counter get incremented in a VM’s cycle?
After the execution of each instruction
How can one tell if an ISA has enough instructions?
When the set of instructions is “Turing Complete” (i.e., can write a Turing machine simulation); As a practical matter, when we can use it to compile/run any program (written in a Turing complete language)
Does a halt instruction need any address?
No
What does these tasks?
- translate mnemonic opcodes into numeric ones (bit patterns)
- track names for locations and translate those names into location numbers when they are used (either in jumps or in loads/stores)
- arrange for initialization of named data locations
Assembler
What is the memory heirarchy?
The memory hierarchy refers to the organization of memory in a computing system, where memory is organized into different levels, each with varying capacities, access speeds, and costs. The levels of memory hierarchy can be categorized based on their proximity to the processor, with faster and more expensive memory located closer to the processor.
Describes a name’s type (or usage) with enough information to check how it is to be used (its specification); describes attributes of a name (e.g. type)
Declaration
Describes the details of an implementation; Allocates storage, or provides an implementation of a function.
Definition
In C, you can’t use “extern” on a ___.
Definition
There must be only one ___ of a name in a scope, but there can be multiple ___ of a name, as long as they are all the same.
- definition
- declarations
The scope of a ___ extends to the end of the file or block.
Declaration
Why is only one definition allowed for a name?
How would the compiler pick the right one?
What does a compiler say about:
void parseExpr() { /* ... */ parseTerm(); /* ... */ } void parseTerm() { /* ... */ parseExpr(); /* ... */ }
an error for the first call to parseTerm(), as it’s not declared where it is first used!
Flag to compile each .c file to an object file
-c
Brings together several separately compiled files into one executable; Matches declarations and definitions for each name.
Linker
The set of strings of characters from some alphabet
Language
Languages can be classified by the kind of ___ needed to recognize them.
Grammar
Consists of a finite set of rules (called “productions”) and a start symbol (a nonterminal).
A Grammar
A language consists of strings of ___ symbols.
Terminal
BNF is a type of notation for
Grammars
In BNF, means “produces” or “can become”
::= (or ->)
In BNF, means “or”, which separates alternatives.
|
How to represent a terminal symbol in BNF.
Not in angled brackets