No student devices needed. Know more
30 questions
In MIPS, which of the following is used when calling a function?
jal
sb
add
li
In MIPS, how are arguments by convention passed to a function?
They are stored in the stack
They are stored in registers $a0
–$a3
They are stored in the data segment
They are stored in registers $t0
–$t3
In MIPS, which register is by convention used to store the return value of a function?
$v0
$a0
$t0
$s0
By convention, what is the primary difference between the $t
registers and $s
registers in MIPS?
$t
: used for arithmetic operations
$s
: used for logical operations
$t
: stores function arguments$s
: stores temporary values
$t
: may not be preserved across function calls
$s
: preserved across function calls
$t
: used for data transfers
$s
: used for arithmetic and logical operations
In MIPS, how do you access the second element of a 32-bit integer array stored in memory?
(The memory address of the array is stored in $s0
.)
lw $t0, 2($s0)
la $t0, 4($s0)
lw $t0, 4($s0)
lb $t0, 8($s0)
In MIPS, how would the wam
field be accessed?
(The memory address of the struct is stored in $s0
.)
lw $t0, 18($s0)
lw $t0, 20($s0)
lw $t0, 19($s0)
lw $t0, 16($s0)
In MIPS, which registers are used to store the result of mult
?
$hi
$mul
$v0
After executing this, what are the contents of $lo
and $hi
?
$lo
= 3
$hi
= 10
$lo
= 10
$hi
= 3
$lo
= 30
$hi
= 100
$lo
= 100
$hi
= 30
What does this do?
Calculate the sum of $t0
and $t1
Calculate the product of $t0
and $t1
Increment $t0
until it's equal to $t1
Decrement $t0
until it's equal to $t1
What is the result of 0b1010 & 0b1100
?
· · ·
0b1010
0b1100
0b1000
0b100
0b1100
0b10
What is the result of 0b1111 | 0b0011
?
· · ·
0b1111
0b0011
0b1111
0b0011
0b1110
0b111
What is the result of 0b1010 ^ 0b1100
?
· · ·
0b1010
0b1100
0b1010
0b1100
0b0110
0b0101
Given an integer x
, how can you check if its n
th bit is set (1
) or unset (0
)?
x & (1 << n)
x | (1 << n)
x ^ (1 << n)
x << (1 << n)
What is the basic format of an IEEE 754-1985 single-precision floating point number?
(Mantissa means the fraction component.)
Sign (1 bit)
Exponent (8 bits)
Mantissa (23 bits)
Sign (1 bit)
Exponent (11 bits)
Mantissa (52 bits)
Sign (1 bit)
Exponent (4 bits)
Mantissa (27 bits)
Sign (1 bit)
Exponent (5 bits)
Mantissa (26 bits)
You may need some working out space for the next one.
https://cgi.cse.unsw.edu.au/~cs1521/22T3/topic/floating_point/slides
OK!
🤷♀️
🔥🔥🔥 😈😈😈 🔥🔥🔥
Convert the decimal number
10.25
to its IEEE 754-1985 single-precision binary representation.
Convert the decimal number 10.25 to its IEEE 754-1985 single-precision binary representation.
· · ·
Step 1: Convert the integer part (10) to binary.
10 = 0b1010
· · ·
Step 2: Convert the fractional part (0.25) to binary.
0.25 = 1/4 = 1/(2²) = 0b0.01
· · ·
Step 3: Combine them.
0b1010 + 0b0.01 = 0b1010.01
· · ·
Step 4: Normalise the binary representation by moving the point to the front.
0b1010.01 = 0b1.01001 × 2³
As it was moved three positions to the left, the exponent is 3.
· · ·
Step 5: Add the bias to the exponent (127 for single-precision floating point numbers).
exponent = 3 + bias = 3 + 127 = 130 = 0b10000010
· · ·
Step 6: Combine the sign bit, exponent and mantissa.
sign bit (positive) = 0
exponent (using 0b10000010 above) = 10000010
mantissa (using 0b1010.01 above; the first 1 is implicit; add 0s to make 23 digits) = 01001000000000000000000
∴ 0 10000010 01001000000000000000000
OK!
😵💫
How many bytes does a valid UTF-8 encoded code point occupy?
4 bytes
It depends
How many bytes are used to represent a single ASCII character in UTF-8 encoding?
1 byte
2 bytes
4 bytes
It depends
Given a UTF-8 encoded string in C, how would you determine the number of characters in the string?
Use the strlen
function
Iterate through it, count the number of bytes, then divide by 4
Iterate through it while checking bytes for valid UTF-8 starting sequences
Convert it to UTF-16, then count the number of characters
The layout of UTF-8
OK!
😵💫
Which of the following binary representations are not valid UTF-8 encoding sequences?
What is the purpose of an inode in a UNIX filesystem?
It stores file data
It maintains a list of file names within a directory
It's a security feature
It stores file metadata (permissions, timestamps, etc.)
What is a file descriptor?
A unique integer assigned to each file opened by a process
A type of file format such as .doc or .pdf
A special data structure used for file operations
The size of the file in bytes
Which of the following is true?
A symbolic link contains the path to another file or directory, whereas a hard link points to its inode
A symbolic link can only point to a file or directory within the same filesystem, whereas a hard link can span across different filesystems
A symbolic link can be created only by the superuser, whereas a hard link can be created by any user
A symbolic link duplicates the file's content, whereas a hard link shares the same content
In C, how can you check whether or not a file exists before accessing it?
Using the file_exists
function
Checking the return value of the fopen
function
Checking the file size
It's not possible to check for file existence before access in C
FILE *f = fopen("data.txt", "r");
· · ·
Which of the following sets the file position indicator to the 100th byte of the file?
(Assume the file exists and contains valid data.)
fseek(f, 99, SEEK_SET);
fseek(f, 100, SEEK_CUR);
fseek(f, 100, SEEK_END);
fseek(f, -99, SEEK_SET);
If data.txt
was created by echo abc > data.txt
, what does this output?
EOF
c
A runtime error because the fseek
function is used incorrectly
\0
What does this print?
"Hello, world!" three times, followed by "Hi there!" five times, in that exact order
Sometimes "Hello, world!" three times, followed by "Hi there!" five times, and other times "Hi there!" five times, followed by "Hello, world!" three times
"Hello, world!" three times and "Hi there!" five times, but the order of each line is not guaranteed
Nothing as it doesn't compile
Which of the following causes a deadlock?
(There is only one correct answer.)
Explore all questions with a free account