About this chapter
How to answer a code question
Translate the C using the stated input locations and data widths. Read the supplied inputs; do not hard-code example answers. Meet the required outputs and preserve other input memory. Each question states whether you are writing a short snippet or a complete function.
C operations
Use the question’s stated data model
Starting state & test cases
Use any supported temporary registers and label names. Ctrl/⌘ + Enter checks your answer.
One valid solution
Other instruction sequences can pass the same tests. Viewing this marks the question as reviewed.
Trace your program
Inspect the state before each instruction and the final result. The trace keeps the first 200 steps plus the final state. Register aliases used by your code appear with their widths. Stack entries are 8-byte hexadecimal values; return addresses are simulated instruction indexes.
PRACTICE CHECKPOINT
End of this set
Skipped questions and viewed solutions remain available to practice.
Syntax reference & what the checker supports
Operands
$5 immediate · %eax register · A named memory
(%edx) indirect · -4(%ebp) displacement · 8(%edx,%ecx,4) base + index × scale + displacement
Registers: RAX, RBX, RCX, RDX, RSI, RDI, RBP, RSP and R8–R15, with 32-, 16- and 8-bit aliases (for example EAX/AX/AL, R8D/R8W/R8B). Use lowercase or uppercase with a % prefix.
Instructions
mov, lea, add, sub, imul (two or three operands), cmp, test, and, or, xor, neg, inc, dec, not, nop; shl/sal, shr, sar; pushq, popq, call, ret, leave; movzbw/movzbl/movzbq/movzwl/movzwq; movsbw/movsbl/movsbq/movswl/movswq/movslq; SETcc byte results.
jmp; je/jz; jne/jnz; jg, jge, jl, jle; js, jns; jo, jno; ja, jae, jb, jbe and their usual aliases.
Use b/w/l/q for 8/16/32/64-bit data. Omitting a normal instruction’s suffix lets the lab infer its width from a register, or default to 32 bits for legacy memory-only exercises. PUSH/POP always use the 64-bit stack here. Shifts accept $0..$255 or %cl. Calls and jumps require local labels. SETcc accepts a byte register or byte memory destination. Extension moves require a smaller register/memory source and a wider register destination. Directives, indirect calls, division, floating-point/SIMD, RDTSC and system calls are outside this bounded subset. Native inline-C examples use GCC separately; the browser practices their concepts and deterministic counter-half calculations.
cmp source, destination sets flags from destination − source. Arithmetic updates flags too; mov and lea preserve them. Symbols and labels are case-sensitive. Use # or // for comments; a semicolon separates instructions.
Checks execute up to 10,000 instructions per case. Passing means the listed cases match; it is not a proof for every possible input or a full C compiler. Assembly arithmetic wraps to the selected operand width; ordinary C signed overflow is undefined, so the C exercises avoid it.
Add your own questions
Question banks are JSON, separate from the interface and interpreter. Add an entry to an existing bank, or list a new bank in data/manifest.json. Topic filters and counts update automatically.
Download a working question template · Read the authoring guide ↗
Imported questions are kept for this session only. Publishing them for everyone requires adding the JSON file to the repository.
Progress & study notes
This course is self-contained. Start with values and bits, then follow one small concept at a time. Each concept includes a complete example, an explanation to compare with your own, focused practice and relevant earlier review. No external slides are needed.
Marked read is a reading bookmark, not a mastery score. Questions passed before revealing a solution count as solved independently. Drafts and progress stay in this browser; nothing is uploaded or synchronized. Use “Whole chapter review” or “All practice” to revisit the larger bank.
The original 32-bit refresher remains available separately. The guided path uses Linux x86-64 LP64. The interpreter provides exact-width integer operations, bounded memory and a simulated stack; it does not execute native code. This course covers the supplied assembly topics and extensions, not the entire CSCI 2122 syllabus.
Read the course design and coverage notes ↗ · Read the control-flow and inline-assembly coverage review ↗
References: Intel instruction manuals · GNU AT&T syntax · System V AMD64 ABI