2505 Test 2 Review Flashcards

(64 cards)

1
Q

how many bytes does pushq %rbp allocate

A

8

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

subq $32, %rsp

is doing what?

A

This line moves the stack pointer down, allocating 32 bytes of room for the stack frame for the function

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

a function receives a parameter. this is the assembly code where the parameter is placed in a stack frame:
movl %esi, -24(%rbp)
At what address is the parameter value stored?

A

%rbp - 24

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

what is happening here:
movl -20(%rbp), %eax
imull -24(%rbp), %eax
movl %eax, -8(%rbp)

A

the code is computing the product of 2 parameters and setting it equal to a local variable

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

which comes first, destination or source?

A

source

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

what do registers look like?

A

%eā€?ā€x

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

what kind of assembly instructions would copy data from RAM to a register?

A

movl where first operand is address, second is register
leave
ret

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

what should be done before copying a string?

A

calloc(strlen(varName)+1, sizeof(char))

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

what is represented by the value 0?

A

NULL

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

how many args does malloc take?

A

1

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

args for calloc?

A

(num of elems, byte size per element)

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

format for creating a mask

A

0x(number)(letter) (8 bits)

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

what kind of mask would make everything 0?

A

& 0

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

what kind of 1 byte mask would make everything 1?

A

0xF

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

mask to extract bit N

A

mask = 1 &laquo_space;N;

return ((x & mask)&raquo_space; N);

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

what should the most significant bit of a positive integer be?

A

0

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

pattern for converting from binary to decimal

A

8421

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

what goes in empty spots for left shifts?

A

0

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

what is 10 in hexadecimal?

A

A

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

when do we fill 1s in the empty positions after a right shift?

A

only when the number is negative (most significant bit is 1)

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

how many bytes does a uint16_t occupy

A

2

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

when you calloc a char array what is the first parameter?

A

strlen(str) + 1

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

when using malloc or calloc with strings what should you do to the string length?

A

add 1

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

difference between movq and movl?

A

movq is for 64 bit, movl is for 32 bit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
difference bw strncpy and strcpy?
strncpy only copies part of a string, takes dest, source, idx args
26
what should you do when there are two different pointer types?
type cast
27
what do while loops look like in assembly?
1) unconditional jmp (start) 2) conditional BACKWARDS jump (end) DO WHILES will not have a jump to the test loop
28
what does if-else look like in assembly?
1) conditional FORWARD jmp (start is right before the cmp statement, end is jump location) 2) unconditional jump
29
je
jump if 0
30
jne
jump if nonzero
31
jg
jump if +
32
js
jump if -
33
jl
jump if signed neg
34
what kind of assembly instructions would copy data from register to RAM?
mov where first operand is register, second is address | INCLUDES PUSH
35
what would be considered a local automatic variable in the stack?
anything that isn't storing a parameter
36
how many bytes is uint8
1 byte
37
which register holds the return value?
%eax
38
if a register name starts with r...
a 64 bit value is being manipulated
39
How would you write C2 in hexadecimal format?
0xC2
40
How many bits in a byte?
8
41
Little endian order...
flips the order of the two hexdump values GO BACKWARDS
42
for hexdump problems, when you perform a typecast of uint16_t...
two chunks of the memory will be used and in little endian order (since its 2 bytes)
43
how many bytes is 64 bit
8 bytes
44
how many bytes is 32 bit
4 bytes
45
8*16 =
128
46
how many bytes are in the stack frame?
rbp (8) + the value associated with subq
47
char* is a
string
48
args for memcpy()
destination, source, total memory
49
function to make a copy of a string
strcpy()
50
function to ALLOCATE memory for a string copy
calloc(strlen(str)+1, size(char))
51
function to copy int array
memcpy()
52
allocate memory to make a copy of the struct PIE
Pie* pecan = calloc(1, sizeof(Pie));
53
what does -1 look like in binary
a bunch of 1s
54
how many bits is a nybble
4
55
what is 0x7FFFFFFF in binary
0111 1111 1111 1111...
56
true or false: overflow can change a positive number into a negative number with addition
true
57
instead of saying value of a pointer say
target
58
what does sal do
shift to the left by n bits
59
strlen(str) + 1 is only needed when using
calloc
60
operation needed to step into next array element
+ sizeof(type)
61
how do you know if a value is even? (binary)
the low bit should be 0
62
what is 0x01 in binary?
00000001 (8 bits)
63
how to convert from decimal to hex
``` take the number div by 16 take that answer div 16 ... the final hex value is the remainder from each division BACKWARDS ```
64
when reading hex values from a hexdump the values should be written
BACKWARDS