I have 64-bit MacOS assembly code which performs binary search on an array. Binary search in standard C library is:
void* bsearch (const void* key, const void* base,
size_t num, size_t size,
int (*compar)(const void*,const void*));
And my assembly looks like
mov %edi,0x2(%rsp)
mov $0x2010,%r8d
mov $0x4,%ecx
lea 0x2(%rsp),%rdi
callq <bsearch@plt>
I am wondering if there is any definitive order of parameters that the bsearch
takes, i.e. is there any way of knowing what rdi, ecx, r8d
correspond to here? Is it key
, base
, compar
?