Exercise 3: Why This Is a "Contract," Contrasted With assembly1-7 — Possible Solution ==================================================================== ASSEMBLY1-7'S OWN CONVENTION ------------------------------ Per assembly1-7, LC-3's own calling convention (save R7, restore R7 before RET) was something the PROGRAMMER invented, entirely for their own program's internal use. Nothing outside that specific program ever needed to know or agree with it — no operating system, no external library, no other author's code was ever going to call into or be called from that LC-3 program. If the convention were changed partway through, the only consequence would be within that one self-contained program. WHY X86-64'S CONVENTIONS ARE GENUINELY DIFFERENT: A REAL CONTRACT ------------------------------ Per this chapter's own explanation, x86-64 calling conventions (System V AMD64 ABI, Microsoft x64) aren't invented by any individual programmer at all — they're fixed, external, standardized agreements that the operating system, every system library, and every other compiler ALSO assumes will be followed. A single hand-written x86-64 assembly program routinely calls into, and is called by, code it had no hand in writing at all (OS functions, library functions, code from a completely different compiler). For all of that code to work together correctly, every piece of it has to honor the exact same argument-passing rules, exact same callee-saved-register rules, and (on Windows) the exact same shadow-space requirement — none of which any single program gets to redefine for itself. THE PRACTICAL CONSEQUENCE OF THAT DIFFERENCE ------------------------------ Per this chapter's own closing point, violating LC-3's own convention would only ever break that one program's own internal logic — a bug fully contained within code the same author wrote. Violating an x86-64 calling convention breaks an agreement code OUTSIDE the programmer's control (the OS, a library, another compiler's output) was relying on — meaning the failure can show up as a crash or corrupted data somewhere else entirely, disconnected from the actual mistake, which is exactly why this chapter calls it a "contract" rather than merely "a convention." WHY THIS WORKS AS AN ANSWER ------------------------------ It contrasts the SCOPE of each convention precisely (self-contained and programmer-chosen for LC-3, versus external and mandatory for x86-64), and explains the real practical consequence of that difference — who gets hurt, and how visibly, when the convention is violated — rather than just restating that one is "more complicated."