2505 Test 2 Review Flashcards
how many bytes does pushq %rbp allocate
8
subq $32, %rsp
is doing what?
This line moves the stack pointer down, allocating 32 bytes of room for the stack frame for the function
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?
%rbp - 24
what is happening here:
movl -20(%rbp), %eax
imull -24(%rbp), %eax
movl %eax, -8(%rbp)
the code is computing the product of 2 parameters and setting it equal to a local variable
which comes first, destination or source?
source
what do registers look like?
%e”?”x
what kind of assembly instructions would copy data from RAM to a register?
movl where first operand is address, second is register
leave
ret
what should be done before copying a string?
calloc(strlen(varName)+1, sizeof(char))
what is represented by the value 0?
NULL
how many args does malloc take?
1
args for calloc?
(num of elems, byte size per element)
format for creating a mask
0x(number)(letter) (8 bits)
what kind of mask would make everything 0?
& 0
what kind of 1 byte mask would make everything 1?
0xF
mask to extract bit N
mask = 1 «_space;N;
return ((x & mask)»_space; N);
what should the most significant bit of a positive integer be?
0
pattern for converting from binary to decimal
8421
what goes in empty spots for left shifts?
0
what is 10 in hexadecimal?
A
when do we fill 1s in the empty positions after a right shift?
only when the number is negative (most significant bit is 1)
how many bytes does a uint16_t occupy
2
when you calloc a char array what is the first parameter?
strlen(str) + 1
when using malloc or calloc with strings what should you do to the string length?
add 1
difference between movq and movl?
movq is for 64 bit, movl is for 32 bit
difference bw strncpy and strcpy?
strncpy only copies part of a string, takes dest, source, idx args