Final Review Flashcards

(108 cards)

1
Q

Which op code is used for branch instructions?

A

00

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

What is the op code for call instructions?

A

01

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

What is the op code for format 3 instructions?

A

10 and 11

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

What’s the difference between a subroutine and a leaf subroutine?

A

A leaf subroutine will have no further subroutine calls within it, and therefore we don’t need to start with a save instruction.

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

Which instruction do most subroutines start with?

A

The save instruction

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

What does the save instruction actually do?

A

It shifts the stack pointer, and therefore the frame pointer in reference to the %sp

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

What does a format 1 instruction look like?

A

01 + (displacement 30)

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

What does a format 2 branch instruction look like?

A

00 + a + cond (4-bit) + op2 (010) + 22 bit immediate

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

What does a format 2 sethi instruction look like?

A

00 + rd (5-bit) + 100 + 22 bit immediate

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

What does a format 3 instruction with two source registers look like?

A

1 x + rd (5-bit) + op3 (6-bit) + rs1 (5-bit) + 0 + 0’s (8-bit) + rs2 (5-bit)

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

What does a format 3 instruction with one source register and an immediate constant look like?

A

1 x + rd (5-bit) + op3 (6-bit) + rs1 (5-bit) + 1 + 13-bit immediate constant

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

If you wanted to save n (a 32-bit int) into the %o0 register, what two lines of code would you use?

A

sethi n&raquo_space; 10, %o0

or %o0, n & 0x3ff, %o0

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

If you want to save n (a 32-bit int) into %o0 using the hi and lo instructions, what would that look like?

A

sethi %hi(n), %o0

or %o0, %lo(n), %o0

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

What is the synthetic instruction that combines the “sethi” and “or” instruction to store n in %o0?

A

set n, %o0

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

What is an open subroutine?

A

A piece of code that has been defined, that we do not jump via memory to, but that expands every time it’s called

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

What is a closed subroutine?

A

Code that we branch to whenever we want to use it, and then return to the next instruction immediately after the branch

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

Define:

endian

A

Relating to a system of ordering data in a computer’s memory, where the most significant (big-endian) or least significant (little-endian) byte is put first

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

Is SPARC big or little endian?

A

SPARC is big-endian

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

How would you access the i-th element in a one-dimensional array?

A

address_of_first_element + i * size_of_element_in_bytes

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

Use the var macro to do the following:

int a[100]

A

var(a, 4, 4*100)

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

How would you access the i-th element from:
var(a, 4, 4*100),
and store the result into %o0?
(i.e. what three instructions do you need?)

A

sll %i_r, 2, %o0 !o0 = i * 4
add %fp, %o0, %o0 !o0 = %fp + i * 4
ld [%o0 + a], %o0

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

What does the save instruction do to the registers?

A

It changes the register mapping so that new registers are provided

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

What does the restore instruction do?

A

It restores the register mapping on subroutine return

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

What is the stack pointer?

A

<p>It points to the top of the stack, that is, last occupied stack memory element</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the frame pointer?
It holds a stored copy of the stack pointer before it is changed to provide more storage
26
When does the frame pointer actually get moved?
It stays in the same place until we move the stack pointer
27
What register is used for %sp?

%o6

28
Which register is used for %fp?

%i6

29
What is the difference between "the stack" and a stack machine?
Although they are both first-in-last-out data structures, a stack machines uses popping and pushing to perform arithmetic and logical operations on the top two items. The stack does not.
30
How does the stack work with memory allocation, and how does it grow?
It grows downwards from the top of memory. When we allocate space for our use, we subtract from the stack pointer, moving the %sp to a new address, and keeping the %fp at the old location of the %sp
31
How do we keep the %sp double word aligned?
By making sure it's divisible by 8
32
How much memory do we need for our registers?
92 bytes
33

How does the code work for chopping?

We start with our -92 bytes for registers, subtract the amount of memory we need for any automatic variables, and then we chop it with "& -8"

34
How does chopping work?
Chopping is a bitwise-and operation; for example, if you wanted chop something that is halfword aligned, you perform a bitwise-and operation with the number you wish to chop (in binary) and two (in binary). The result is your halfword-aligned address
35

What does the save instruction do?

The save instruction both performs addition and saves the content of the stack pointer in %fp.
36
What are the six load instructions?
ldsb: load signed byte ldub: load unsigned byte ldsh: load signed halfword lduh: load unsigned halfword ld: load ldd: load double
37

How does the ifelse macro work?

It takes four arguments. It compares the first two: if they are equal, it returns the third argument. Otherwise, it returns the 4th.
38
If you wanted to load a first variable, called a0, into %l1, what instruction would you use?
ld [%fp - 4] %l1
39
How does the ifelse macro work?
It takes four arguments. It compares the first two: if they are equal, it returns the third argument. Otherwise, it returns the 4th.
40

Which condition codes: | bl

(N xor V) = 1

41

Which condition codes: | ble

Z or (N xor V) = 1

42
Which condition codes:be
Z = 1
43

Which condition codes: | bne

Z = 0

44

Which condition codes: | bge

(N xor V) = 0

45

Which condition codes: | bg

Z or (N xor V) = 0

46
Which condition codes are used with signed branches?
N, V, and Z
47
Which condition codes are used with unsigned branches?
C and Z
48

Which condition codes: | blu

C = 1

49

Which condition codes: | bleu

C or Z = 1

50

Which condition codes: | bgeu

C or Z = 0

51

Which condition codes: | bgu

C = 0

52

Which condition codes: | bneg

N = 1

53
Which condition codes:bpos
N = 0
54
Which condition codes:bz
Z = 1(be)
55

Which condition codes: | bnz

Z = 0 | (bne)

56
Which condition codes:bvs
V = 1
57

Which condition codes: | bvc

V = 0

58
Which condition codes:bcs
C = 1(blu)
59

Which condition codes: | bcc

C = 0 | (bgeu)

60
What are the four condition codes?
N: negative Z: zero C: carry-out V: overflow
61
The manipulation of the symbols that represent numeric codes is facilitated by what?
A macro processor
62
What is m4?
The UNIX macro processor.
63
Define "accumulator"
An accumulator is a register used to contain the results of an arithmetical or logical operation
64
Define "register"
A location in a store of data, used for a specific purpose and with quick access time
65
What is a stack?
A stack is a first-in-last-out data structure in which only the top stack elements are accessible
66
What is the ALU?
The arithmetic logic unit. The unit in a computer that carries out arithmetical and/or logical operations
67
Stacks and registers are two forms of what?
Memory
68
Why would one use a register instead of the stack?
Registers are useful when values enter into the computation in a less structured manner
69
In a computer, what is an "address"?
A location in memory
70
What does the program counter do?
It keeps track of the address of the next instruction to be executed
71
What is assembly language?
Symbols representing numeric values
72
Define "macro".
Symbol, name, or key that represents a list of commands, actions, or keystrokes. Many programs allow you to create macros so that you can enter a single character or word to perform a whole series of actions.
73
How many arguments can a macro take?
A macro can have up to nine arguments
74
If there are arguments present with a macro, how does the processor handle them?
The arguments are evaluated; if they are in quotes, the quotes are stripped and the arguments are NOT evaluated; any $n subs are made. The macro is fully expanded and pushed back to output stream.
75
What is a location counter?
It is a symbol representing the memory address of the instruction being assembled.
76
What is "eval"?
It's a built in macro that takes in a string argument to represent an arithmetic expression. It then evaluates the expression and returns its value in the form of a numerical string.
77
What is a macro processor?
Identifies macro tokens and arguments in its input stream, and substitutes the macro definitions in their place to be rescanned
78
Define "define" in m4
A built in macro that defines its first argument to be a macro token to be replaced on evaluation by its second argument
79
What is an accumulator machine?
It combines an operand from memory with the contents of a single register (the accumulator) and stores the result of the operation in the accumulator. The contents of the accumulator can be loaded from and stored into memory.
80
What is a label?
A symbol whose value is the address where the instruction or data it references will be located in memory
81

What are the four registers?

%g for global %o for output %l for local %i for input
82
What is a symbol table?
A table of symbol-value pairs that is created by the macro processor on the first pass and utilised on the second pass
83
What is MAR?
Memory access register
84

Which registers does .div work with?

It takes what's in %o0, divides %o1 into it, and stores the result in %o0
85
What is MDR?
Memory data register
86
What type of architecture is SPARC?
Load/store
87
Which register does trap get its service request instruction from?
%g1
88
Which condition code is set when the sign of the addends is the same but the sign of the result is different?
V (overflow)
89
What type of architecture is SPARC?
Stack architecture
90
Which register is used for the subroutine return address?
%i7
91
Which condition code is set when the sign of the addends is the same but the sign of the result is different?
V (overflow)
92
What does CISC stand for?
Complex instruction set computing
93
Which register is used for the subroutine return address?
%i7
94
Which formula is used to find a negative number in diminished radix complement?
r^n - 1 - b
95
What does CISC stand for?
Complex instruction set computing
96
Which formula is used to find a negative number in radix complement?
r^n - 1 - b + 1
97
Which formula is used to find a negative number in diminished radix complement?
r^n - 1 - b
98
Which shift corresponds to multiplication by two?
sll (shift left logical)
99
Why does mulscc set the N and V condition codes?
It's so that when multiplication is being done, we can test N ^ V to see if a one or zero should be shifted in
100
What would your save instruction be if you wanted to have room for 5 int vars on the stack?
save %sp, (-92 - (5 * 4)) & -8, %sp
101
What is the mapping, for row major order, of the i-th, j-th, k-th element of an array named arr? int arr[di][dj][dk]
%fp + arr + (i * dj * dk * 4) + (j * dk * 4) + (k * 4)
102
Why does mulscc set the N and V condition codes?
It's so that when multiplication is being done, we can test N ^ V to see if a one or zero should be shifted in
103
What would your save instruction be if you wanted to have room for 5 int vars on the stack?
save %sp, (-92 - (5 * 4)) & -8, %sp
104
What is the mapping, for row major order, of the i-th, j-th, k-th element of an array named arr? int arr[di][dj][dk]
%fp + arr + (i * dj * dk * 4) + (j * dk * 4) + (k * 4)
105
call %o0 | is a synthetic instruction for which code?
jmpl %o0, %o7
106
What is the "ret" instruction a synthetic instruction for?
jmpl %i7 + 8, %g0
107
How do we return from a leaf subroutine?
retl
108
How to we return from a non-leaf subroutine?
ret | restore