Assembly Language MCQ
Test your Assembly Language knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.
How This Practice Test Works
Every question below expands right on this page — click a question to reveal its four options, pick the one you think is correct, and you'll get instant feedback along with the correct answer and a short explanation of the reasoning. Questions are grouped by difficulty, so start with the 40 beginner questions to confirm your fundamentals, work through the 40 intermediate ones, and finish with the 20 advanced questions that mirror what exams and technical screenings actually ask. There's no sign-up, no timer, and no limit — retake the test as often as you like.
Curated by Tech Baithak Editorial Team · Last updated: June 2026
1
What is assembly language?
Correct Answer
A low-level programming language where instructions correspond closely to machine instructions for a specific processor architecture
Explanation
Assembly language uses mnemonic codes (MOV, ADD, JMP) representing machine instructions. An assembler converts it to binary machine code.
2
What tool converts assembly language source code to machine code?
Correct Answer
Assembler
Explanation
An assembler (e.g., NASM, MASM, GAS) translates assembly mnemonics into binary machine code. A linker then combines object files into an executable.
3
What does the MOV instruction do in x86 assembly?
Correct Answer
Copies a value from source to destination
Explanation
MOV dst, src copies the value from src to dst. It does not clear the source. For example, MOV EAX, 5 loads 5 into EAX.
4
What is a register?
Correct Answer
A small, fast storage location directly inside the CPU
Explanation
Registers are the fastest storage available. x86-64 has general-purpose registers (RAX, RBX, RCX, RDX, RSI, RDI, RSP, RBP, R8-R15), control registers, and others.
5
What does the ADD instruction do?
Correct Answer
Adds the source operand to the destination and stores the result in the destination
Explanation
ADD EAX, EBX adds EBX to EAX and stores the result in EAX. It sets the Carry, Zero, Sign, and Overflow flags accordingly.
6
What is the stack pointer (SP/RSP)?
Correct Answer
A register pointing to the top of the call stack
Explanation
RSP (64-bit) / ESP (32-bit) always points to the current top of the stack. PUSH decrements RSP; POP increments RSP.
7
What does PUSH do in x86 assembly?
Correct Answer
Decrements the stack pointer and writes the operand to the new top of stack
Explanation
PUSH EAX decrements ESP by 4 (or RSP by 8 in 64-bit) and stores EAX at the new stack top.
8
What does POP do?
Correct Answer
Reads the top of stack into the operand and increments the stack pointer
Explanation
POP EAX loads the value at the current stack top into EAX, then increments ESP by 4.
9
What is the instruction pointer (IP/RIP)?
Correct Answer
A register holding the address of the next instruction to execute
Explanation
RIP (64-bit) / EIP (32-bit) is the program counter. It automatically increments after each instruction fetch. JMP and CALL change it directly.
10
What does the JMP instruction do?
Correct Answer
Unconditionally transfers control to the specified address
Explanation
JMP label sets the instruction pointer to the address of label, continuing execution from there unconditionally.
11
What does CMP do?
Correct Answer
Compares two operands by subtracting and setting flags without storing the result
Explanation
CMP A, B computes A - B and sets the CPU flags (ZF, SF, OF, CF) without modifying A or B. Conditional jumps (JE, JL, JG) use these flags.
12
What is the Zero Flag (ZF)?
Correct Answer
Set when the result of an operation is zero
Explanation
ZF is 1 if the last arithmetic/logic result was zero. CMP A, A sets ZF=1 (they are equal). JE (jump if equal) checks ZF.
13
What does JE (or JZ) do?
Correct Answer
Jumps to the label if the Zero Flag is set (operands were equal)
Explanation
JE (Jump if Equal / Jump if Zero) branches to the target if ZF=1, typically used after CMP.
14
What is CALL used for?
Correct Answer
Pushing the return address and jumping to a function
Explanation
CALL func pushes the address of the next instruction onto the stack (return address), then jumps to func.
15
What does RET do?
Correct Answer
Pops the return address from the stack and jumps to it
Explanation
RET pops the return address (saved by CALL) from the stack and transfers control to that address, returning from the function.
16
What is a label in assembly?
Correct Answer
A symbolic name for an address, used as a target for jumps and calls
Explanation
loop: is a label. JMP loop or CALL func uses labels. The assembler resolves them to numeric addresses.
17
What is the Carry Flag (CF)?
Correct Answer
Set when an unsigned arithmetic operation produces a carry out of or borrow into the most significant bit
Explanation
CF=1 on unsigned overflow (carry out) or underflow (borrow). JC (Jump if Carry) and JNC use CF.
18
What does SUB do?
Correct Answer
Subtracts the source from the destination and stores the result in the destination
Explanation
SUB EAX, EBX computes EAX = EAX - EBX and sets flags.
19
What does INC do?
Correct Answer
Adds 1 to the operand in place
Explanation
INC EAX is equivalent to ADD EAX, 1 but more compact. It modifies all flags except CF.
20
What does DEC do?
Correct Answer
Subtracts 1 from the operand in place
Explanation
DEC ECX is equivalent to SUB ECX, 1. Modifies flags except CF.
21
What does NOP do?
Correct Answer
No Operation — occupies one instruction cycle without doing anything
Explanation
NOP is used for alignment padding, timing delays, and as a placeholder in shellcode (NOP sled).
22
What is the base pointer (BP/RBP) used for?
Correct Answer
Serving as a stable reference point for the current stack frame, used to access local variables and parameters
Explanation
RBP points to the saved frame base. Local variables are at [RBP-n]; function parameters are at [RBP+n]. Created by the function prologue.
23
What is the function prologue?
Correct Answer
The instructions at a function's start that set up the stack frame: PUSH RBP; MOV RBP, RSP
Explanation
The prologue saves the caller's RBP, sets RBP to the current RSP creating a new frame, and optionally allocates local variable space.
24
What are the major data sizes in x86 assembly?
Correct Answer
byte(8), word(16), dword(32), qword(64)
Explanation
In x86: byte=8 bits, word=16 bits, dword=32 bits, qword=64 bits. Instructions use size qualifiers: BYTE PTR, WORD PTR, DWORD PTR, QWORD PTR.
25
What does XOR EAX, EAX do?
Correct Answer
Sets EAX to zero — the fastest way to zero a register
Explanation
XOR of any value with itself is 0. XOR EAX, EAX is preferred over MOV EAX, 0 because it produces a shorter encoding and clears flags.
26
What does AND do in assembly?
Correct Answer
Performs a bitwise AND, clearing bits not set in the mask
Explanation
AND EAX, 0xFF masks EAX to its lowest 8 bits. AND is used for bit masking and clearing specific bits.
27
What does OR do?
Correct Answer
Performs a bitwise OR, setting bits that are set in either operand
Explanation
OR EAX, 0x01 sets bit 0 of EAX. OR is used for setting specific bits.
28
What does the TEST instruction do?
Correct Answer
Performs a bitwise AND and sets flags without storing the result
Explanation
TEST EAX, EAX checks if EAX is zero (sets ZF=1 if EAX=0) without modifying EAX. Used before JZ/JNZ.
29
What is the difference between little-endian and big-endian?
Correct Answer
Little-endian stores the least significant byte first; big-endian stores the most significant byte first
Explanation
x86 is little-endian: the value 0x12345678 stored at address 0x100 is 78 56 34 12 in memory. ARM can be either.
30
What is a system call?
Correct Answer
A request to the operating system kernel to perform privileged operations like I/O
Explanation
System calls (e.g., read, write, exit) are invoked via SYSCALL (x86-64 Linux), INT 0x80 (legacy x86), or SYSENTER.
31
What does MUL do?
Correct Answer
Unsigned multiplication of EAX by the operand, storing the double-width result in EDX:EAX
Explanation
MUL EBX multiplies EAX * EBX. The 64-bit result is in EDX:EAX (high 32 bits in EDX). IMUL is the signed version.
32
What does DIV do?
Correct Answer
Unsigned division of EDX:EAX by the operand, with quotient in EAX and remainder in EDX
Explanation
DIV EBX divides EDX:EAX by EBX. Quotient → EAX, Remainder → EDX. IDIV is the signed equivalent.
33
What is a directive in assembly?
Correct Answer
An assembler command that controls code generation or defines data, not translated into machine code
Explanation
Directives like DB (define byte), DW (define word), SECTION, GLOBAL, EXTERN are instructions to the assembler, not the CPU.
34
What is the .data section?
Correct Answer
The section for initialized global and static data
Explanation
The .data section holds initialized variables like msg db "Hello", 0. The .bss section holds uninitialized data reserved with RESB/RESW/RESD.
35
What is the .text section?
Correct Answer
The section containing the executable program code (instructions)
Explanation
The .text section contains the machine code instructions. It is typically read-only and executable.
36
What does LEA do?
Correct Answer
Loads the effective address (computed memory address) into a register without accessing memory
Explanation
LEA EAX, [EBX + ECX*4 + 8] computes the address and puts it in EAX. Often used for pointer arithmetic or fast multiply tricks.
37
What is SHL used for?
Correct Answer
Shifting bits to the left, which multiplies by powers of 2
Explanation
SHL EAX, 1 multiplies EAX by 2. SHL EAX, 3 multiplies by 8. Faster than MUL for power-of-2 multiplication.
38
What is the Overflow Flag (OF)?
Correct Answer
Set when a signed arithmetic result overflows the destination's capacity
Explanation
OF is set when signed overflow occurs (e.g., adding two large positive numbers results in a negative). JO (jump on overflow) uses OF.
39
What does XCHG do?
Correct Answer
Atomically swaps the values of two operands
Explanation
XCHG EAX, EBX swaps EAX and EBX. XCHG with memory is always atomic (used for spinlock implementations).
40
What is LOOP used for?
Correct Answer
Decrements ECX and jumps to label if ECX != 0
Explanation
LOOP target decrements ECX and jumps if ECX != 0. Set ECX to the iteration count beforehand.
1
What is the calling convention?
Correct Answer
A set of rules specifying how functions receive parameters, return values, and which registers must be preserved
Explanation
Calling conventions (cdecl, stdcall, System V AMD64 ABI, Microsoft x64) define argument passing order/registers, caller/callee-saved registers, and return value location.
2
What is the System V AMD64 ABI calling convention?
Correct Answer
First 6 integer/pointer arguments in RDI, RSI, RDX, RCX, R8, R9; return value in RAX
Explanation
Linux/macOS 64-bit (System V ABI): args in RDI, RSI, RDX, RCX, R8, R9 (then stack). Return in RAX. Callee-saved: RBX, RBP, R12-R15.
3
What is the difference between caller-saved and callee-saved registers?
Correct Answer
Caller-saved registers must be saved by the caller before a call (may be modified by callee); callee-saved must be saved and restored by the callee
Explanation
In System V AMD64: RAX, RCX, RDX, RSI, RDI, R8-R11 are caller-saved. RBX, RBP, R12-R15 are callee-saved (the called function must restore them).
4
What is CISC vs RISC?
Correct Answer
CISC has many complex variable-length instructions (x86); RISC has fewer, fixed-length, simple instructions (ARM, MIPS, RISC-V)
Explanation
x86 is CISC — one instruction can do complex things like load, compute, and store. RISC architectures separate loads, computes, and stores for simpler hardware and pipelining.
5
What is alignment in memory addressing?
Correct Answer
Storing data at addresses that are multiples of the data size for performance and hardware requirements
Explanation
A 4-byte int should be at an address divisible by 4. Misaligned accesses may work but are slower (or cause a fault on some architectures).
6
What is a segment register and what are the common ones?
Correct Answer
Registers (CS, DS, SS, ES, FS, GS) that, in segmented memory models, hold base addresses of memory segments
Explanation
CS=Code Segment, DS=Data, SS=Stack, ES/FS/GS=Extra. In 64-bit long mode, segments are mostly flat (base=0), but FS/GS are used for thread-local storage.
7
What is an interrupt?
Correct Answer
A signal causing the CPU to suspend current execution and call an interrupt service routine (ISR)
Explanation
Hardware interrupts come from devices (keyboard, timer). Software interrupts (INT n) are intentional. The CPU saves state, calls the ISR, and returns with IRET.
8
What is the purpose of CPUID instruction?
Correct Answer
Queries the processor for identification and feature information
Explanation
CPUID with EAX=0 returns vendor string. EAX=1 returns processor type and feature flags (SSE support, etc.). Used for runtime feature detection.
9
What is SSE in the context of x86?
Correct Answer
Streaming SIMD Extensions — providing 128-bit XMM registers and vector operations for processing multiple data elements at once
Explanation
SSE (and SSE2/3/4, AVX, AVX-512) provide SIMD (Single Instruction, Multiple Data) operations. ADDPS adds four floats simultaneously using XMM registers.
10
What does the LEAVE instruction do?
Correct Answer
Tears down the stack frame: MOV RSP, RBP; POP RBP
Explanation
LEAVE is the function epilogue shorthand equivalent to MOV RSP, RBP followed by POP RBP, restoring the caller's stack frame.
11
What is the red zone in x86-64 System V ABI?
Correct Answer
A 128-byte area below RSP that leaf functions can use as scratch space without adjusting RSP
Explanation
Signal handlers and interrupt handlers must not use the red zone. Kernel code uses -mno-red-zone. Leaf functions can use [rsp-8] through [rsp-128] without a PUSH.
12
What is MOVZX and MOVSX?
Correct Answer
MOVZX zero-extends a smaller value into a larger register; MOVSX sign-extends it
Explanation
MOVZX EAX, BYTE PTR [mem] loads a byte and pads upper bits with 0. MOVSX EAX, BYTE PTR [mem] replicates the sign bit for signed values.
13
What is a NOP sled used for in security?
Correct Answer
A large sequence of NOP instructions in shellcode that gives a buffer overflow payload a wide landing zone
Explanation
In exploit development, a NOP sled precedes shellcode. If the attacker overflows to any NOP, execution "slides" to the shellcode without needing exact address prediction.
14
What is address space layout randomization (ASLR)?
Correct Answer
An OS security feature that randomizes the base addresses of the stack, heap, and libraries on each run to defeat hardcoded address exploits
Explanation
ASLR makes it harder for attackers to jump to specific addresses (like gadgets or libraries). Combined with DEP/NX, it significantly raises the bar for exploitation.
15
What is stack canary?
Correct Answer
A secret value placed between local variables and the saved return address to detect buffer overflow corruption
Explanation
The compiler inserts a canary value (e.g., GCC's -fstack-protector). Before RET, the canary is checked — if modified by a buffer overflow, the program terminates.
16
What is return-oriented programming (ROP)?
Correct Answer
An exploit technique chaining existing "gadgets" (small code sequences ending in RET) to perform arbitrary operations without injecting code
Explanation
ROP defeats DEP/NX by reusing existing executable code. Attackers build a chain of gadget addresses on the stack; each gadget does a small operation then RETurns to the next.
17
What does the LOCK prefix do?
Correct Answer
Makes the subsequent instruction atomic by asserting the bus lock signal
Explanation
LOCK XCHG/CMPXCHG/ADD/INC ensures the read-modify-write operation is atomic on multi-core systems, preventing other CPUs from accessing the same memory location.
18
What is CMPXCHG used for?
Correct Answer
Atomically comparing a memory location to EAX and, if equal, replacing it with another register value
Explanation
LOCK CMPXCHG [mem], ECX: if [mem]==EAX, store ECX; else load [mem] into EAX. This is the CAS (Compare-And-Swap) operation for lock-free algorithms.
19
What is a memory fence (MFENCE, LFENCE, SFENCE)?
Correct Answer
Memory barrier instructions that enforce ordering of memory operations relative to other memory accesses
Explanation
MFENCE serializes all memory operations. LFENCE serializes loads. SFENCE serializes stores. Required when dealing with out-of-order execution and weak memory models.
20
What is the difference between PUSH/POP and PUSHA/POPA?
Correct Answer
PUSH/POP operate on a single register; PUSHA/POPA push/pop all general-purpose registers at once (16/32-bit only)
Explanation
PUSHA pushes AX/CX/DX/BX/SP/BP/SI/DI (or 32-bit equivalents) in one instruction. PUSHA/POPA are not available in 64-bit mode.
21
What is pipelining and how does it affect assembly programming?
Correct Answer
CPU execution of multiple instruction stages (fetch, decode, execute, writeback) in parallel; data hazards and branch mispredictions cause stalls
Explanation
Pipelining improves throughput but can stall on data hazards (using a result too soon) or control hazards (branch misprediction). Careful instruction ordering can minimize stalls.
22
What is the difference between IMUL and MUL in x86?
Correct Answer
MUL performs unsigned multiplication; IMUL performs signed multiplication
Explanation
MUL EBX: unsigned EAX * EBX → EDX:EAX. IMUL EBX: signed EAX * EBX → EDX:EAX. IMUL also has two and three operand forms: IMUL EAX, EBX, 5.
23
What does the SHR instruction do?
Correct Answer
Logical right shift — shifts bits right, filling with 0s, dividing unsigned values by powers of 2
Explanation
SHR EAX, 2 divides EAX by 4 for unsigned values, filling upper bits with 0. SAR (arithmetic right shift) preserves the sign bit for signed division.
24
What does the NEG instruction do?
Correct Answer
Negates the operand (two's complement negation: result = 0 - operand)
Explanation
NEG EAX computes EAX = 0 - EAX. For EAX=5, result is -5 (0xFFFFFFFB in two's complement). Sets CF if operand was non-zero.
25
What is the purpose of the REP prefix with string instructions?
Correct Answer
Repeats the following string instruction (MOVS, STOS, CMPS, SCAS, LODS) ECX times, decrementing ECX each iteration
Explanation
REP MOVSB copies ECX bytes from DS:ESI to ES:EDI, decrementing ECX and advancing ESI/EDI. Used for memory copy operations.
26
What does MOVS (MOVSB/MOVSW/MOVSD) do?
Correct Answer
Copies a byte/word/dword from DS:ESI to ES:EDI and updates the pointers
Explanation
MOVSB copies one byte and increments or decrements ESI and EDI based on the Direction Flag. Used with REP for bulk memory copies.
27
What does STOS (STOSB/STOSW/STOSD) do?
Correct Answer
Stores AL/AX/EAX to ES:EDI and updates EDI
Explanation
REP STOSD fills ECX dwords at ES:EDI with EAX. Used to initialize memory blocks (e.g., memset).
28
What is the Direction Flag (DF) used for?
Correct Answer
Controlling whether string instructions auto-increment (DF=0, CLD) or auto-decrement (DF=1, STD) the ESI/EDI pointers
Explanation
CLD clears DF (forward direction, increment). STD sets DF (backward direction, decrement). The ABI requires DF to be 0 at function calls.
29
What is CALL FAR vs CALL NEAR?
Correct Answer
NEAR CALL pushes only EIP and jumps within the current segment; FAR CALL pushes CS and EIP and can jump to a different segment
Explanation
In modern 64-bit protected mode, far calls are rarely used directly. In legacy real and protected modes, far calls change the code segment register.
30
What is the Sign Flag (SF) set to after an operation?
Correct Answer
Set to the most significant bit of the result — 1 for negative (if treating as signed), 0 for positive
Explanation
SF mirrors the MSB of the result. JNS (Jump if Not Sign) and JS (Jump if Sign) use SF for signed comparisons.
31
What is the Parity Flag (PF) used for?
Correct Answer
Set when the low byte of the result has an even number of 1-bits; used historically for data transmission error detection
Explanation
PF=1 if the number of set bits in the low byte of the result is even. JPE/JPO use PF. Rarely used in modern code but available for SIMD status operations.
32
What is a protected mode in x86?
Correct Answer
A CPU operating mode enabling memory protection, privilege rings (0-3), virtual memory, and multitasking beyond the 1MB real-mode limit
Explanation
Protected mode (introduced with 80286) provides segmentation, paging, and privilege levels. Modern OSes run in protected or long mode. Real mode is 16-bit, 1MB address space.
33
What is long mode (64-bit mode) in x86-64?
Correct Answer
The 64-bit operating mode of x86-64 processors with 64-bit addresses, 16 GPRs, and flat segmentation (mostly disabled segment limits)
Explanation
Long mode (IA-32e) provides 64-bit addresses (48 bits currently used), 16 GPRs (RAX-R15), REX prefixes for 64-bit operands, and eliminates most legacy segment limits.
34
What is PUSHF/POPF used for?
Correct Answer
Saving and restoring the EFLAGS register on the stack
Explanation
PUSHF pushes EFLAGS onto the stack. POPF restores EFLAGS from the stack. Used to save and restore the entire flag state across function calls.
35
What is the difference between JBE and JLE?
Correct Answer
JBE (Jump if Below or Equal) is for unsigned comparison using CF and ZF; JLE (Jump if Less or Equal) is for signed comparison using SF, OF, ZF
Explanation
Use JBE/JAE/JA/JB for unsigned comparisons. Use JLE/JGE/JG/JL for signed comparisons. Mixing them after CMP produces incorrect results for negative numbers.
36
What is a procedure prologue and epilogue in 64-bit code?
Correct Answer
Prologue: PUSH RBP; MOV RBP, RSP; SUB RSP, n — saves frame and allocates locals. Epilogue: MOV RSP, RBP (or LEAVE); POP RBP; RET
Explanation
The prologue establishes the stack frame. The epilogue tears it down. Some leaf functions omit the frame pointer (RBP) for performance. RSP must be 16-byte aligned at CALL.
37
What is a vtable call in assembly terms?
Correct Answer
An indirect call through a pointer stored in a table: MOV RAX, [RCX]; CALL [RAX + offset]
Explanation
C++ virtual dispatch: MOV RAX, [RCX] loads the vptr; CALL [RAX + n*8] calls the n-th virtual function. Two memory indirections vs one for non-virtual calls.
38
What is the hot and cold code split technique?
Correct Answer
Placing frequently executed (hot) code at the start of a cache line and infrequently used (cold) code elsewhere to maximize cache utilization
Explanation
Keeping hot paths in nearby cache lines reduces i-cache misses. PGO (Profile-Guided Optimization) reorders functions to separate hot and cold code sections.
39
What is the difference between movdqu and movdqa?
Correct Answer
movdqa (aligned) requires 16-byte aligned memory; movdqu (unaligned) works on any address but may be slower
Explanation
movdqa moves 128 bits to/from a 16-byte aligned XMM register. movdqu handles unaligned addresses. On modern Intel/AMD, the penalty is minimal for unaligned accesses.
40
What is instruction-level parallelism (ILP) and superscalar execution?
Correct Answer
Multiple independent instructions executing simultaneously on separate execution units within a single CPU core
Explanation
Modern CPUs have multiple ALUs, FPUs, and load/store units. With 4-wide superscalar execution and 6 execution ports, up to 4 instructions can retire per cycle if independent.
1
What is branch prediction and what is its impact on performance?
Correct Answer
A CPU technique of guessing conditional branch outcomes in advance; mispredictions flush the pipeline costing ~15-20 cycles
Explanation
Modern CPUs speculatively execute branches. Misprediction flushes the pipeline. Write branch-friendly code (predictable patterns, CMOV for branchless alternatives).
2
What are CPU caches and their impact on assembly optimization?
Correct Answer
Fast memory next to the CPU that reduces main memory access latency
Explanation
L1 (~4 cycles), L2 (~12 cycles), L3 (~40 cycles), RAM (~200 cycles). Cache-friendly access patterns (sequential, not random) are the biggest assembly performance factor.
3
What is SIMD and how does it improve throughput?
Correct Answer
Single Instruction, Multiple Data — one instruction applies the same operation to multiple data elements packed in wide registers (XMM, YMM, ZMM)
Explanation
VADDPS ymm0, ymm1, ymm2 adds eight 32-bit floats simultaneously using AVX 256-bit registers, achieving 8x throughput over scalar addition.
4
What is speculative execution and the Spectre vulnerability?
Correct Answer
CPUs speculatively execute instructions past branches; Spectre exploits this by using cache timing to leak data from speculatively accessed memory
Explanation
Spectre tricks the CPU's branch predictor to speculatively access memory the attacker shouldn't read. Side-channel timing reveals the speculatively loaded data.
5
What is the hardware prefetcher?
Correct Answer
CPU hardware that detects access patterns and automatically loads upcoming data into cache before it is requested
Explanation
Stride prefetchers detect sequential or constant-stride access and prefetch ahead. Random access defeats the prefetcher, causing cache misses. PREFETCHT0 is the software hint.
6
What is out-of-order execution?
Correct Answer
CPU reordering and executing independent instructions before earlier instructions complete to maximize unit utilization
Explanation
Modern CPUs issue instructions out-of-order when dependencies allow. Results appear in-order (in-order retirement). This can cause up to 4x throughput improvement for independent instructions.
7
What is the Tomasulo algorithm?
Correct Answer
A hardware algorithm for out-of-order execution using register renaming and reservation stations to eliminate false data hazards
Explanation
Tomasulo's algorithm renames registers to physical registers, eliminating WAR and WAW hazards, allowing independent instructions to execute freely out of order.
8
What is AARCH64 (ARM64) and how does it differ from x86-64?
Correct Answer
ARM's 64-bit RISC ISA with 31 general-purpose registers, fixed 32-bit instruction encoding, and explicit load/store architecture
Explanation
AArch64 has 31 GPRs (x0-x30), a fixed 4-byte instruction size, explicit load/store (no memory-operand ALU), and uses a link register (x30) for call/return.
9
What are hardware performance counters?
Correct Answer
CPU registers that count low-level events (cache misses, branch mispredictions, instructions retired) for performance profiling
Explanation
PMU (Performance Monitoring Unit) counters (RDPMC/RDTSC) track L1 cache misses, branch mispredictions, IPC, etc. Tools like perf and Intel VTune use them.
10
What is the purpose of RDTSC in timing and what are its caveats?
Correct Answer
Reads the Time Stamp Counter (CPU cycle count); out-of-order execution and CPU frequency scaling require LFENCE/CPUID for accurate micro-benchmarks
Explanation
RDTSC is fast but can be reordered. Use LFENCE; RDTSC; LFENCE or RDTSCP for serialized timing. Modern Intel CPUs have a constant TSC not tied to clock scaling.
11
What is a micro-operation (uop) in modern Intel architecture?
Correct Answer
The internal RISC-like operations that complex x86 instructions are decoded into, enabling out-of-order execution on execution units
Explanation
x86 instructions are decoded into 1-4 micro-ops by the front-end. The out-of-order engine schedules uops independently. ADD has 1 uop; PUSH has 2 (compute address + store).
12
What is the µop cache (decoded instruction cache) and its benefit?
Correct Answer
A cache storing decoded micro-ops, allowing the CPU to bypass front-end decode for hot loops, improving throughput and power efficiency
Explanation
The µop cache (e.g., Intel's Decoded ICache) holds ~1500 µops. Hot loops that fit in the µop cache bypass x86 decode entirely, enabling higher throughput.
13
What is ASLR and how does it interact with position-independent code (PIC)?
Correct Answer
ASLR randomizes load addresses; PIC (using relative addressing and GOT/PLT) enables shared libraries to work correctly regardless of base address
Explanation
PIC uses RIP-relative addressing (call [rip+offset]) for code and a Global Offset Table (GOT) for data addresses, allowing the OS to load the library at any address.
14
What is the PLT (Procedure Linkage Table) and how does lazy binding work?
Correct Answer
A trampoline table in shared libraries; lazy binding calls the resolver on first use, then overwrites the GOT entry with the actual function address
Explanation
First call to printf goes through PLT → resolver → resolves address → writes to GOT. Subsequent calls go PLT → GOT (direct). Lazy binding reduces startup time.
15
What is the difference between PIC and PIE?
Correct Answer
PIC is for shared libraries; PIE (Position Independent Executable) applies the same technique to executables, enabling ASLR for the main program
Explanation
PIE executables use relative addressing and can be loaded at random base addresses by ASLR. Required for full ASLR protection of the main executable.
16
What is Return-Oriented Programming (ROP) chain construction?
Correct Answer
Chaining gadget addresses on the stack so each RET pops the next gadget address, building arbitrary computation from existing code
Explanation
pop rdi; ret followed by an address sets RDI. pop rsi; ret sets RSI. Gadgets performing system call setup let attackers call execve("/bin/sh") without injecting code.
17
What is a shadow stack and how does it prevent ROP?
Correct Answer
A hardware-protected secondary stack storing only return addresses; RET must match both stacks, preventing ROP from overwriting return addresses
Explanation
Intel CET (Control-flow Enforcement Technology) provides a shadow stack. CALL pushes to both stacks; RET checks they match. Mismatches (ROP) cause a fault.
18
What is x87 FPU vs SSE floating-point and why does SSE dominate?
Correct Answer
x87 uses 80-bit extended precision and a stack model; SSE uses 32/64-bit IEEE 754 in XMM registers — more predictable, SIMD-capable, and ABI-preferred
Explanation
x87's stack model is awkward to compile for and its 80-bit precision causes subtle differences vs C double. Modern compilers use SSE2 (mandated by x86-64 ABI) for float/double.
19
What is the cache line size and why does it matter for assembly optimization?
Correct Answer
Typically 64 bytes; a cache line is the unit of transfer between CPU cache and RAM — false sharing and unaligned access waste bandwidth
Explanation
If two variables share a cache line but are written by different CPU cores (false sharing), the cache line ping-pongs between cores. Align hot data to 64 bytes to prevent this.
20
What is the Meltdown vulnerability in terms of assembly?
Correct Answer
An exploit using speculative execution to transiently access kernel memory across privilege boundaries, then inferring it via cache timing
Explanation
Meltdown: user-mode code reads kernel address speculatively before the permission check raises an exception. Cache timing reveals the value. Fixed by KPTI (kernel page-table isolation).