Chapter 1 - Part 1 Flashcards
What does the preprocessor do in C and what does it output?
The preprocessor modifies the original C program and outputs ASCII text.
What does the assembler stage do in a C program, and what does it output.
The assembler stage translates the assembly code into machine language instructions. It is output in a binary format, called a relocatable object program.
What does the compilation stage do in a C program, and what format does it output?
The compilation stage converts the C code into assembly language and outputs the generated code as text (usually with a .s extension).
What does the linking stage do in a C program?
Linking merges other object files referenced by the C program, and outputs an executable file (in machine language binary), which is ready to be loaded into memory.
How do you convert hex to binary using the bc command line tool?
echo ‘obase=2;ibase=16; A’ | bc
First stage of C compilation + clang command
Preprocesser: clang -E hello.c > hello.i
Second stage of C compilation + clang command
Compiler: clang -S hello.c
$ hello.s
Third stage of C compilation + clang command
Assembler: clang -c hello.c
$ hello.o
Fourth stage of C compilation + clang command
Linker: clang hello.c
$ a.out
How large is a word?
Words refer to a fixed size of bytes, but have no fixed size. Most modern machines use either 4 bytes (32 bits) or 8 bytes (64 bits).
Name 4 standard I/O devices.
Keyboard, mouse, display, disk.
For I/O devices, what’s the difference between a controller and an adapter.
A controller is soldered into the motherboard, an adapter plugs into motherboard slot.
What does DRAM stand for?
Dynamic random access memory.
What is a word-sized storage device in the CPU called?
register
What is the program counter in a CPU.
The program counter contains the address of a register holding the next machine language instruction it will execute.
What does ALU stand for in a processor?
arithmetic logic unit
What is a ‘register file’?
A register file is a storage device that consists of multiple registers with unique names.
What does the ‘load’ machine operation do?
Copies data from main memory and stores it in a register, overwriting whatever was previously there.
What does an ‘operate’ operation do?
Copies the contents of two registers to the ALU, performs an arithmetic operation on the two registers, and stores the result in a new register, overwriting what was there.
What does a ‘store’ operation do.
Copies a word from a register to the main memory, overwriting what was there.
What does a ‘jump’ operation do?
Gets a word from the instruction, and copies it to the program counter.
What’s the difference between a machines instruction set architecture and its microarchitecture?
The ISA is an abstraction over the microarchitecture. The ISA describes what each instruction will do, and the microarchitecture handles the actual implementation.
Approximately how much faster can a processor read code from a registry file than main memory?
~ 100x
What does SRAM stand for, and what is it used for on the hardware level?
Static random access memory. It is used to create caches that are smaller than the main memory, but faster and closer to the CPU. These are usually called L1, L2, and L3 caches, and their sizes get larger as the go up in levels.
What does the term locality mean with respect to memory
Locality refers to the tendency for programs to access data and code in localized regions.