Skip to content

Lab 09 fix#160

Open
alexf05 wants to merge 3 commits intomainfrom
lab-09-fix
Open

Lab 09 fix#160
alexf05 wants to merge 3 commits intomainfrom
lab-09-fix

Conversation

@alexf05
Copy link
Copy Markdown

@alexf05 alexf05 commented Mar 26, 2026

Prerequisite Checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Updated relevant documentation (if needed).

Description of changes

This PR resolves the remaining bugs, ABI violations, and typos from the x86_64 transition in lab-09.

Specific fixes include:

  • Reading Materials: Corrected 64-bit calling conventions in the markdown files (e.g., clearing rax for variadic functions like printf and updating 32-bit stack argument examples to 64-bit register arguments).
  • max-c-calls: Fixed a logical bug by changing the signed comparison (jge) to unsigned (jae). Fixed pointer initialization in the solution.
  • regs-preserve: Added the required 16-byte stack alignment (sub rsp, 8) to the support code before calling printf to prevent immediate segfaults. Corrected the stack restoration order (pop rbx vs add rsp, 8) in the solution.

Question for Reviewer (@teodutu): I noticed that the max-c-calls-x86 task currently contains 64-bit code instead of 32-bit, and the max-assembly-calls-x86 task is missing add esp, X stack cleanups for the cdecl calling convention. Should I convert these files back to proper 32-bit assembly in a follow-up commit, or are these x86 legacy folders planned for deletion?

Fix #141

@alexf05 alexf05 requested a review from teodutu March 26, 2026 08:07
alexf05 added 3 commits March 26, 2026 17:44
Update memory-layout and calling-convention reading materials to
correctly reflect the 64-bit System V AMD64 ABI. Add the missing
`xor rax, rax` before variadic function calls and convert 32-bit
stack argument examples to 64-bit register arguments.

Fix #141

Signed-off-by: alexf05 <alexfechet16@gmail.com>
Correct multiple issues introduced during the x86_64 transition:
- max-c-calls: Fix signedness comparison by using `jae` and fix
  pointer initialization bug in the solution. Revert support file.
- regs-preserve: Add required 16-byte stack alignment before calling
  printf and fix the order of stack restoration in the solution.

Fix #141

Signed-off-by: alexf05 <alexfechet16@gmail.com>
Signed-off-by: alexf05 <alexfechet16@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

labs/lab-09: Check x86_64 version

1 participant