An x86-64 Linux caller using the System V AMD64 convention holds a needed counter value of 19 in R10 and a needed index value of 31 in RBX. It will use both values after calling helper. The helper follows the convention but may otherwise use any permitted registers. The caller already has a dedicated 8-byte local stack slot in its allocated frame and correct call-site alignment.
Which actions correctly protect the values they address? Select all that apply. Treat each proposed action separately, without assuming any other register save.
Leave RBX unchanged in the caller across the call, relying on the helper to preserve it.
Copy R10 into R11 before calling, then copy R11 back into R10 afterward.
Store R10 in the dedicated local stack slot before calling, then reload R10 afterward.
Copy R10 into RAX before calling, then copy RAX back into R10 afterward.
Unlock full course notes by signing up
Finding arguments after the prologue
An x86-64 Linux assembly function uses the System V AMD64 convention and receives eight long arguments named a1 through a8, in that order. Each long and return address occupies 8 bytes. At entry, a7 and a8 occupy consecutive stack slots immediately above the return address.
The function executes this prologue without changing any argument registers:
Complete the table for the instant after these instructions. For register locations, enter the lowercase register name. For stack locations, enter the exact integer byte displacement from the current RSP, so a displacement of 32 means [rsp + 32].
Widening C arguments without trusting excess register bits
Two assembly functions implement these C declarations on a 64-bit Linux target:
Each function must return the mathematical value of x as a signed long. On this target, int and unsigned int are 32 bits, long is 64 bits, and signed integers use two's complement representation.
Under the System V AMD64 ABI, the incoming argument occupies edi, the low 32 bits of rdi; the upper 32 bits of the incoming register are unspecified. Each function returns its 64-bit result in rax.
Accounting for recursive call frames
An x86-64 Linux assembly implementation uses the System V AMD64 convention to reproduce this C function for nonnegative inputs:
Every invocation, including the base case, pushes one 8-byte copy of its incoming RBX, then stores its own n in RBX. A non-base invocation calls total(n - 1), adds its saved n to the returned RAX, restores RBX, and returns. The base case returns zero after restoring RBX.
There are no other pushes, stack allocations, or calls. Every call adds an 8-byte return address; each frame's single register push provides the required alignment for its recursive call. The outer call is total(6), and the implementation performs all recursive calls without optimization.
Tracing an assembly load through C structure padding
A C program passes an array of three records to an assembly function on a 64-bit Linux target using the System V AMD64 ABI.
The function is intended to return records[index].total. An object's alignment is the byte-address multiple required at its start. Use these target properties:
Members remain in declaration order, and each begins at the lowest available offset satisfying its alignment. The structure's alignment is its largest member alignment, and its size is rounded up to a multiple of that alignment. No packing options are enabled.