InterviewStack.io LogoInterviewStack.io

Assembly Language and Code Generation Questions

Knowledge and practical skill reading and writing assembly language for relevant instruction set architectures such as ARM Thumb, RISC V, or x86. Core topics include calling conventions and application binary interface details, stack frame layout and management, register usage and allocation, function prologue and epilogue, position independent code and linking, object file and symbol concepts, inline assembly and writing callable assembly routines, and how high level language constructs map to generated code. Candidates should understand compiler backends and optimization passes, how optimization levels change generated code, how inlining, loop transformation, and instruction selection affect performance, and techniques for optimizing critical sections with hand written assembly when appropriate. Familiarity with toolchain behaviors such as assembler and linker flags, compiler diagnostics about generated code, and basic conventions for calling into and out of assembly from higher level languages is expected.

MediumTechnical
40 practiced
Compare and contrast graph-coloring and linear-scan register allocation algorithms. Describe how each constructs live ranges, performs coalescing and spilling, their compile-time complexity, and why JITs often prefer linear-scan while AOT compilers sometimes favor graph-coloring.
EasyTechnical
45 practiced
Write a callable assembly function on x86-64 (Intel syntax) that takes two 64-bit integers and returns their sum. Use the System V AMD64 ABI; provide the assembly implementation and the corresponding C declaration (e.g., uint64_t add(uint64_t a, uint64_t b);). Keep it minimal and correct with respect to ABI-preserved registers.
MediumTechnical
38 practiced
Examine this x86-64 assembly (Intel syntax) and identify the stack frame layout: which offsets correspond to saved registers, local variables, and spilled temporaries? Explain how rbp and rsp are used and compute the offset to a local buffer placed at [rbp-0x30]. Assembly:\n\n push rbp\n mov rbp, rsp\n sub rsp, 0x50\n mov [rbp-0x10], rdi\n mov rax, [rbp-0x20]\n pop rbp\n ret\n\nAssume SysV ABI.
HardTechnical
35 practiced
Given C code with heavy pointer aliasing that prevents many optimizations (loads/stores are assumed to alias), explain how type-based alias analysis, the restrict keyword, and compiler-specific attributes (e.g., __attribute__((noalias))) can help the optimizer. Provide examples and explain how generated assembly can change when aliasing information is improved.
EasyTechnical
33 practiced
When writing inline assembly in GCC/Clang (extended asm syntax), what constraints and precautions must you specify to ensure the compiler generates correct code? Discuss input/output operands, clobber lists, the 'memory' clobber, volatile, and how incorrect constraints can cause undefined behavior.

Unlock Full Question Bank

Get access to hundreds of Assembly Language and Code Generation interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.