Pass function as a parameter

I’m not sure this is the best, but: function A{ Param([scriptblock]$FunctionToCall) Write-Host “I’m calling $($FunctionToCall.Invoke(4))” } function B($x){ Write-Output “Function B with $x” } Function C{ Param($x) Write-Output “Function C with $x” } PS C:\WINDOWS\system32> A -FunctionToCall $function:B I’m calling Function B with 4 PS C:\WINDOWS\system32> A -FunctionToCall $function:C I’m calling Function C with 4 … Read more

Is reserving stack space necessary for functions less than four arguments?

Your quote is from the “calling convention” part of the documentation. At the very least, you do not have to worry about this if you do not call other functions from your assembly code. If you do, then you must respect, among other things, “red zone” and stack alignment considerations, that the recommendation you quote … Read more

What’s the best way to remember the x86-64 System V arg register order?

If you remember C memcpy‘s arg order, and how rep movsb works, that’s most of the way to remembering x86-64 System V. The design makes memcpy(dst, src, size) cheap to implement with rep movsb, except leaving RCX unused in more functions because it’s needed for variable-count shifts more often than anything needs RDX. Then R8 … Read more