64位sysv调用约定将第一个参数放入
global mystrlen mystrlen: xor ecx,ecx ; rcx = 0 dec rcx ; rcx = -1 (0xFFFFFFFFFFFFFFFF) ; rcx = maximum length to scan xor eax,eax ; rax = 0 (al = 0 value to scan for) repne scasb ; scan the memory for AL sub rax,rcx ; rax = 0 - rcx_leftover = scanned bytes + 1 sub rax,2 ; fix that into "string length" (-1 for '\0') ret
。因此,呼叫者rdi
已经为您完成了加载。您可以检查其汇编代码并亲自查看。