Add Function Argument
- The stack or a register is used to pass an argument to a function.
Define a new function argument with the appropriate type, making explicit that such stack position or register is used to hold the argument.
... eax = 1; loc100(); ... void loc100() { ... ... = eax; ... return; }
⇓
... eax = 1; loc100(eax); ... void loc100(int arg1) { ... ... = arg1; ... return; }
Motivation
In a similar fashion as the function return value, it is a common calling convention to pass function arguments in particular registers, the stack, or both. This is platform-specific detail, which should be eliminated for attaining proper code understanding.
Mechanics
- Add a new function argument with the appropriate type.
- Add the register or stack location as argument to all function calls.
- Replace all references to the register or stack location in the function body to the argument name.