Module 9: Intro to C Flashcards

1
Q

Machine Code

A

binary files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Assembly Code

A

text files (.asm)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

C code

A

text files (.c, .h)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Compiler

A

converts a high level language (like C) to low level language (assembly) for example .c to .asm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Assembler

A

converts assembly language to machine language object files (.asm to .obj)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Linker

A

combines multiple object files (.obj) into a single executable object file; e.g. user_program + os.obj –> my_program.obj

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

symbol table

A

created by a compiler to keep track of where data should be stored, the type of data stored, and the scope of the data being stored by the program it compiled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

local variables

A

the “scope” of these variables only exist within the {}. Variables must be declared at the top of the block!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

stack

A

in the context of the C language, the region in data memory where data required to support functions in the C language will be stored (functions such as arguments, local variables, and return values). it is organized like a physical stack: imagine piling one book on top of the next one in a stack of books. this is why it grows “backwards” in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

frame

A

logical grouping of the data on the stack that belongs to a single function. examples of data in the stack are arguments, local variables, and return values. as one function calls another each function will have its own frame.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

frame pointer

A

a register that holds a starting address for the frame or in the case of the LC4, a register holding the location where the calling function’s frame pointer was stored in the active function’s stack frame. sometimes called the base pointer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

return address

A

address in program memory to return after function completes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

prologue

A

assembly code created by the compiler to construct the frame for any given function. it is the first code executed when a function is called. it is also responsible for “pushing” the stack frame for the active function onto the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

epilogue

A

assembly code created by the compiler to “pop” the stack from the active function off of the stack. it copies the return value into the proper location on the stack so that the calling function has access to the returning data (if any) from the active function. it is executed every time a function exits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Big Ideas in C

A

a high level/low level language that binds the gap between a machine level language and high level languages

imperative

procedural

file-oriented (files: a simple abstraction for permanent storage and I/0)

portability: the same C code can be compiled for different ISAs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

prologue:

A

STR R7, R6, #-2
STR R5, R6, #-3
ADD R6, R6, #-3
ADD R5, R6, #0

arguments are pushed onto the stack from right to left
this lets the first argument from the left be the one closest to the callee
that is called “c convention”
it is needed for functions with variable argument counts e.g. printf
it can also lead to the order of evaluation being right to left (e.g. pow(a, ++a) may become pow(3, 3)

17
Q

pass by value vs. pass by reference

A

functions receive “copies” of local variables
recall that arguments to functions were copies of local variables
protects local variables from being modified accidentally

18
Q

Why are variables declared at the start of the function?

A

size of static/automatic variables are known at compile time

also, compiler may compiler line by line, hence right upfront!

19
Q

arrays’ order on the stack

A

the order of arrays on the stack is consistent with the memory address (i.e. in increasing order)
arr[0] - x7FF5
arr[1] - x7FF6
arr[2] - x7FF7