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
Q

what does the instruction mean?

A

primitive operation
- specify operation and its operands
–> operands = necessary variables to perform the operation

26
Q

what are operands?

A

necessary variables to perform the operation

27
Q

types of operands

A

immediate (data), source and destination (registers)

28
Q

what is the register symbol

A

$

29
Q

how many registers does MIPS have?

A

32 general purpose registers

30
Q

what does the assembler do with the MIPS instructions?

A

assembler translates MIPS to machine language

31
Q

what step in the compilation system translates code to MIPS?

A

compiler –> filename.s = MIPS instructions

32
Q

c program:

int a = 10;
int b = 2;

int c = a + b + 2;

MIPS Program:

addi $8, $0, 10

^ what does this line mean?

A

addi $8, $0, 10

$8 –> register $8 holds the value in variable a (a = 10)

  register $8 = $0(0) + 10 
                      = 10 (AKA a)
33
Q

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?

A

addi $9, $0, 2

$9 –> register $9 holds the value in variable b (b = 2)

   register $9 = $0(0) + 2 
                       = 2 (AKA b)
34
Q

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?

A

add $10, $8, $9

register $10 –> holds value in variable c (int c = a + b)

 $10 =  $8 + $9 
    c  =    a   +   b 
        =    10 + 2
35
Q

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?

A

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
Q

what is always the opcode for R-TYPE?

A

000000

37
Q

what are the parts of a 32-bit R-TYPE instruction?

A

opcode (6)
rs (5)
rt (5)
rd (5)
shamt (5)
func (6)

38
Q

what are the parts of a 32-bit I-TYPE instruction?

A

opcode (6)
rs (5)
rt (5)
immediate (16)

39
Q

once the program is in MIPS (assemble program), what does the assembler then do?

A

translates MIPS to machine language
(binary)

40
Q

in the MIPS cheat sheet, what does each part in R-type and I-type get translated to?

A

its binary equivalent

ex) $8 = 01000 for rt (5)

41
Q

what is rt for I-Type?

A

destination register

42
Q

what is rd for R-type?

A

destination register

43
Q

what is rs for both R-type and I-type?

A

source register

44
Q

what is immediate for I-type?

A

constant

45
Q

what is func for R-Type?

A

operation (add)

46
Q

what is shamt for R-type?

A

amount of shift, set to zero in all non-shift instructions