; Sort in ascending order using the insertion sort algorithm an array of signed ; words starting at the address in register RDI and member count (at least 2) ; in register RSI. ;void insertionSort(vector& toSort) // From the book "Theoretical ;{ // algorithms in C++" by Kevin ; for (int i = 0; i < toSort.size(); ++i) // de Keyser (2015) ; for (int j = i - 1; j >= 0; --j) ; if (toSort[j+1] < toSort[j]) ; swap(toSort[j], toSort[j+1]); ; else // These 2 lines don't exist in the ; break; // aforementioned book! ;} ; Let the outer loop index (i) be RDX, and the inner loop index (j) be RAX. option prologue:none, epilogue:none .code inssort proc _inssort proc .for (RDX = 0: RDX < RSI: RDX++) .for (RAX = RDX, RAX--: !sign?: RAX--) MOV RCX,[RDI+8*RAX+8]; if (toSort[j+1] CMP RCX,[RDI+8*RAX] ; < toSort[j]) .break .if (!less?) XCHG RCX,[RDI+8*RAX] ; swap(toSort[j], MOV [RDI+8*RAX+8],RCX; toSort[j+1]; .endfor .endfor RET _inssort endp inssort endp end