Closed bobcyc closed 4 years ago
Hi bobcyc
Apologies for the long delay in responding.
Reviewing the code in Lesson 5 - I think EAX is PUSHed only to preserve it after the call to slen (https://github.com/DGivney/assemblytutorials/blob/master/code/lesson5/functions.asm#L31).
Leaving EAX as is, means that this SPRINT function has the same behavior as SYS_WRITE. It will return 0 in EAX on success or -1 in EAX on error.
You are correct however, if the function is not expected to return a value, then you would want to POP EAX and restore the program state to before the call to this function.
In Lesson 5, functions.asm, SPRINT: function, four registers are PUSHed (EDX, ECX, EBX, EAX). At the exit of SPRINT: function, only EBX, ECX and EDX are POPped before the RETurn. Should EAX be POPped to clear the stack or will leaving EAX on the stack not leave "noise" on the stack?