Lecture 2 Flashcards
Is assembly considered low level?
Due to the one-to-one correspondence with machine instructions, it is seen as low-level.
Is assembly portable?
No. different processors have different instruction sets.
What are some advantages of higher-level languages.
One HLL statement can correspond to many machine instructions.
They are also machine-agnostic, making them much more portable.
What does the operating system do?
As the name implies, it controls the entire operation of the computer. It is a resource manager and allocator.
All I/O operations performed on a computer system pass through the OS via a standardized interface.
It manages H/W resources and handles the execution of programs/processes.
Linux is _____-based.
Unix
Mac OS X is ______-based.
Unix.
What is a big reason for the success of Unix?
It was written primarily in C and made very few assumptions about the architecture of the computer.
This let it port to many different computers with relatively little effort.
Windows runs on…
Intel or intel compatible processors.
Compilers…
Translate a program in a high-level language into an executable for your operating system.
This involves many stages, and is not to be confused with compiling. Compiling is only one of the stages.
Compiler steps:
Source code
Preprocessor makes it into expanded code.
Compiler makes it into assembly code.
Assembler makes it into object code.
The linker takes the object code, libraries, and other object files, and makes it into executable code.
What are two popular text editors used on Unix?
vim/Emacs
What is gcc?
Uses the GNU C compiler.
Preprocessor
Takes symbol definitions and expands them. Inserts head file text to make a complete program.
Compiler
A syntactically correct program is translated into a “lower” form. Each statement is translated by the compiler into equivalent assembly statements. This is a .s file.
Assembler.
Translated assembly language into actual machine instructions. Object code or .o files.
Linkers.
All object files linked together with system libraries to make an executable file.
What is building?
Compiling/Linking a program.
Typing the name of an executable file…
creates a process that runs the program. Loads the program into memory and initiates execution. Starts at entry point (usually main).
What do interpreters do?
They analyze and execute statements at the same time. This is typically slower because it has to convert as it runs.
Makefile.
myprog: myprog.o
gcc myprog.o -o myprog
myprog.o: myprog.c
gcc -c myprog.c
first line defines a target, myprog and the dependencies.
second line is the recipe to make the target.
second pair of lines makes the .o file for the target.
This can then just be run with $make
More Makefile details.
all: myprog
all target should build entire project conventionally.
.PHONY
With. it’s dependencies are not real targets and do not produce files.