因此,此插入排序是用x86编写的,但嵌入在C中。它还具有一个标志,在对数组的一半进行排序后,我们将其设置为保留。有什么办法可以提高性能?
void asmInsSort(int *list, int arrayLen, int halfpoint) {
_asm
{
mov ecx, arrayLen
mov esi, list
mov ebx, halfpoint
mov eax, 0
more:
cmp ecx, 0 // Compare current arrayLen w/ 0
je done // If it is equal, we are done
mov edi, eax //J = I
push eax //push eax (i) to free up register for key
mov eax, [esi + edi] //Key = Array[i] technically j
sub edi, 4 //J - 1
mov edx, arrayLen //K …Run Code Online (Sandbox Code Playgroud) x86 assembly inline-assembly micro-optimization insertion-sort
如何在不使用任何内置方法或功能且不关心角色的情况下,在恒定时间(O(1))中获得字母(1-26)中字符的数值/位置?