CSCI3130 FINAL EXAM QUESTIONS AND ANSWERS
100% SOLVED
Why do you need to make register rax 0 before calling C inbuilt function: printf? - ANSWER
printf uses a variable number of arguments and rax specifies how many SSE registers (for
floating-points) are used for the arguments. In our case we don't use any.
Major difference between high-level language vs low-level languages? - ANSWER High level
languages have a high level of abstraction from the hardware.
Explain the term abstraction in regards to programming languages? - ANSWER Making a
sandwich
-- High level of abstraction: push a button to make a sandwich. No need to know any details
of how to make sandwich
-- Low level of abstraction: need to know how to place the components of the sandwich,
where should the bread go, where should the cheese go and so on.
-- No level of abstraction can be should be able to make bread, cheese and other
components.
What are the advantages of learning assembly language? - ANSWER • Some architectures
don't have C compilers...
-- Instead, they have embedded systems and/or micro-controllers
• Writing compilers
,• Real speedups
• Develop a better understanding of how the processor/compiler/language functions
How many general-purpose registers are there in x86_64 processor? - ANSWER 16
Why do you need to make register rdx 0 before division? - ANSWER Any non- zero number
will make the dividend {rdx,rax} a very large number.
What happens to rdx and rax after the mul instruction? - ANSWER -Leftmost 64 bits of the
result are stored in rdx
-Rightmost 64 bits of the results are stored in rax
How do we recognize comments in assembly code? - ANSWER Semicolon (;)
What does "global" assembler directive do? - ANSWER Allows assembly functions and labels
to be accessible to code in other object files (.o)
System calls are performed using which instruction? - ANSWER syscall
What instruction is used to call assembly functions, as well as external (C, C++, Fortran)
functions? - ANSWER call
, Distinguish between section .text and section .data. - ANSWER Executable assembly
instructions are typically placed in the .text section and static data/variable declarations are
placed in the .data section
Syscall argument order: - ANSWER rdi, rsi, rdx, r10, r8, r9
Function argument order: - ANSWER rdi, rsi, rdx, rcx, r8, r9
Distinguish between db, dw, dd, and dq. - ANSWER •db = 1 byte or 8 bits
•dw = 2 bytes (word) or 16 bits
•dd = 4 bytes (double word) or 32 bit
•dq = 8 bytes (quadword) or 64 bits
f register rsi = 10 and rdx = 16, what would be the value of rax after the following instruction?
lea rax, [rdx+rsi*8] - ANSWER 96
Let's assume the following array "Array" with 16 64-bit integers:
Array: dq 3, 5, 9, 81, 13, 2, 6, 24, 33, 21, 19, 40, 93, 48, 91, 78
Using the array "Array" answer what value is moved to the %rax register based on the
following instructions:
mov rdi, 5
100% SOLVED
Why do you need to make register rax 0 before calling C inbuilt function: printf? - ANSWER
printf uses a variable number of arguments and rax specifies how many SSE registers (for
floating-points) are used for the arguments. In our case we don't use any.
Major difference between high-level language vs low-level languages? - ANSWER High level
languages have a high level of abstraction from the hardware.
Explain the term abstraction in regards to programming languages? - ANSWER Making a
sandwich
-- High level of abstraction: push a button to make a sandwich. No need to know any details
of how to make sandwich
-- Low level of abstraction: need to know how to place the components of the sandwich,
where should the bread go, where should the cheese go and so on.
-- No level of abstraction can be should be able to make bread, cheese and other
components.
What are the advantages of learning assembly language? - ANSWER • Some architectures
don't have C compilers...
-- Instead, they have embedded systems and/or micro-controllers
• Writing compilers
,• Real speedups
• Develop a better understanding of how the processor/compiler/language functions
How many general-purpose registers are there in x86_64 processor? - ANSWER 16
Why do you need to make register rdx 0 before division? - ANSWER Any non- zero number
will make the dividend {rdx,rax} a very large number.
What happens to rdx and rax after the mul instruction? - ANSWER -Leftmost 64 bits of the
result are stored in rdx
-Rightmost 64 bits of the results are stored in rax
How do we recognize comments in assembly code? - ANSWER Semicolon (;)
What does "global" assembler directive do? - ANSWER Allows assembly functions and labels
to be accessible to code in other object files (.o)
System calls are performed using which instruction? - ANSWER syscall
What instruction is used to call assembly functions, as well as external (C, C++, Fortran)
functions? - ANSWER call
, Distinguish between section .text and section .data. - ANSWER Executable assembly
instructions are typically placed in the .text section and static data/variable declarations are
placed in the .data section
Syscall argument order: - ANSWER rdi, rsi, rdx, r10, r8, r9
Function argument order: - ANSWER rdi, rsi, rdx, rcx, r8, r9
Distinguish between db, dw, dd, and dq. - ANSWER •db = 1 byte or 8 bits
•dw = 2 bytes (word) or 16 bits
•dd = 4 bytes (double word) or 32 bit
•dq = 8 bytes (quadword) or 64 bits
f register rsi = 10 and rdx = 16, what would be the value of rax after the following instruction?
lea rax, [rdx+rsi*8] - ANSWER 96
Let's assume the following array "Array" with 16 64-bit integers:
Array: dq 3, 5, 9, 81, 13, 2, 6, 24, 33, 21, 19, 40, 93, 48, 91, 78
Using the array "Array" answer what value is moved to the %rax register based on the
following instructions:
mov rdi, 5