lecture 8 Flashcards

GNU Compiler Collection (GCC) : Compile, Assemble, Machine Language

1
Q

3 compilation steps

A
  1. compiler
  2. assembler
  3. linker
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what enters the compiler?

A

filename.c –> your program in high level language (text)

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

what is the gcc compiler command?

A

gcc -s filename.c

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

what does the gcc -s filename.c create?

A

when this is entered into the terminal and completes, an assembly program is created (filename.c –> filename.s)

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

what does the compiler change your program to?

A

filename.s –> assembler program

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

what is the .s/assembler program?

A

set of text instructions used to program the processor

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

what enters the assembler?

A

filename.s (assembly program)

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

what is the gcc command for the assembler?

A

gcc -c filename.s

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

what does the gcc -c filename.s create?

A

filename.o –> object program/machine program (binary)

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

what is the .o/object program?

A

machine program –> set of binary instructions that configure and control hardware

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

what enters the linker?

A

filename.o –> machine program (binary)

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

what is the gcc command for the linker?

A

gcc filename.o

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

what does the gcc filename.o create?

A

executable program (a.out)

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

who is the intended user for the machine program?

A

hardware (computer)

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

highest level language

A

highest level of abstraction, closest to human language, java python etc
your code basically
text

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

assembly language

A

lowest level of abstraction, specific to processor architecture (RISC CISC), syntax is human readable but language of machine
text

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

machine language

A

no abstraction, not human readable, syntax is binary encoded instructions and data, configure and control hardware (MIPS, processor, specific)
binary

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

instruction set architecture

A

combines instructions with registers, addressing modes, data types

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

MIPS

A

microprocessor without interlocked pipelined stages
RISC architecture

20
Q

3 MIPS Instruction Types:

A
  1. R-TYPE
  2. I-TYPE
  3. J-TYPE
21
Q

what is R-TYPE?

A

instruction operands are registers

22
Q

what is I-TYPE?

A

instruction operands are registers and a constant (immediate) value

23
Q

anatomy of R-TYPE instruction

A

operation $1, $2, $3

$1 –> destination operand
$2 and $3 –> source operands
(variables, arguments, etc)

24
Q

anatomy of I-TYPE instruction

A

operation i $1, $2, 1

i –> immediate (how to tell its I-TYPE)
$1 –> destination operands
$2 –> source operands
1 –> immediate operand (constant)

25
what does the instruction mean?
primitive operation - specify operation and its operands --> operands = necessary variables to perform the operation
26
what are operands?
necessary variables to perform the operation
27
types of operands
immediate (data), source and destination (registers)
28
what is the register symbol
$
29
how many registers does MIPS have?
32 general purpose registers
30
what does the assembler do with the MIPS instructions?
assembler translates MIPS to machine language
31
what step in the compilation system translates code to MIPS?
compiler --> filename.s = MIPS instructions
32
c program: int a = 10; int b = 2; int c = a + b + 2; MIPS Program: addi $8, $0, 10 ^ what does this line mean?
addi $8, $0, 10 $8 --> register $8 holds the value in variable a (a = 10) register $8 = $0(0) + 10 = 10 (AKA a)
33
c program: int a = 10; int b = 2; int c = a + b + 2; MIPS Program: addi $8, $0, 10 addi $9, $0, 2 ^ what does this line mean?
addi $9, $0, 2 $9 --> register $9 holds the value in variable b (b = 2) register $9 = $0(0) + 2 = 2 (AKA b)
34
c program: int a = 10; int b = 2; int c = a + b + 2; MIPS Program: addi $8, $0, 10 addi $9, $0, 2 add $10, $8, $9 ^ what does this line mean?
add $10, $8, $9 register $10 --> holds value in variable c (int c = a + b) $10 = $8 + $9 c = a + b = 10 + 2
35
c program: int a = 10; int b = 2; int c = a + b + 2; MIPS Program: addi $8, $0, 10 addi $9, $0, 2 add $10, $8, $9 addi $10, $10, 2 ^what does this line mean?
addi $10, $10, 2 register $10 --> holds value in variable c (a + b) from line above *now adding 2 to this register since its c = a + b + 2 (cant do this in one MIPS instruction --> had to split it into 2) $10 = $10 + 2 c = (a + b) + 2 = (10 + 2) + 2
36
what is always the opcode for R-TYPE?
000000
37
what are the parts of a 32-bit R-TYPE instruction?
opcode (6) rs (5) rt (5) rd (5) shamt (5) func (6)
38
what are the parts of a 32-bit I-TYPE instruction?
opcode (6) rs (5) rt (5) immediate (16)
39
once the program is in MIPS (assemble program), what does the assembler then do?
translates MIPS to machine language (binary)
40
in the MIPS cheat sheet, what does each part in R-type and I-type get translated to?
its binary equivalent ex) $8 = 01000 for rt (5)
41
what is rt for I-Type?
destination register
42
what is rd for R-type?
destination register
43
what is rs for both R-type and I-type?
source register
44
what is immediate for I-type?
constant
45
what is func for R-Type?
operation (add)
46
what is shamt for R-type?
amount of shift, set to zero in all non-shift instructions