Array.asm

This file defines the library for arrays and algorithms thereof.

See Also

Authors

  • Neil G.  Dickson
Summary
Array.asmThis file defines the library for arrays and algorithms thereof.
indexOfFunctions for finding the index of a value in an array
Functions
Array8_indexOfReturns the index of a byte in an array, or -1 if it’s not in the array
Array16_indexOfReturns the index of a word in an array, or -1 if it’s not in the array
Array32_indexOfReturns the index of a dword in an array, or -1 if it’s not in the array
Array64_indexOfReturns the index of a qword in an array, or -1 if it’s not in the array
Array128_indexOfReturns the index of a dqword in an array, or -1 if it’s not in the array
lastIndexOfFunctions for finding the last index of a value in an array
Functions
Array8_lastIndexOfReturns the last index of a byte in an array, or -1 if it’s not in the array
Array16_lastIndexOfReturns the last index of a word in an array, or -1 if it’s not in the array
Array32_lastIndexOfReturns the last index of a dword in an array, or -1 if it’s not in the array
Array64_lastIndexOfReturns the last index of a qword in an array, or -1 if it’s not in the array
Array128_lastIndexOfReturns the last index of a dqword in an array, or -1 if it’s not in the array
equalsFunctions for checking equality of two arrays
Functions
Array8_equalsChecks the equality of two arrays
Array16_equalsChecks the equality of two arrays
Array32_equalsChecks the equality of two arrays
Array64_equalsChecks the equality of two arrays
Array128_equalsChecks the equality of two arrays
binarySearchFunctions for finding values in sorted arrays
Functions
ArrayByte_binarySearchFinds a byte in a sorted array of bytes with a binary search
ArraySByte_binarySearchFinds a signed byte in a sorted array of signed bytes with a binary search
ArrayWord_binarySearchFinds a word in a sorted array of words with a binary search
ArraySWord_binarySearchFinds a signed word in a sorted array of signed words with a binary search
ArrayDword_binarySearchFinds a dword in a sorted array of dwords with a binary search
ArraySDword_binarySearchFinds a signed dword in a sorted array of signed dwords with a binary search
ArrayReal4_binarySearchFinds a 4-byte real in a sorted array of 4-byte reals with a binary search
ArrayQword_binarySearchFinds a qword in a sorted array of qwords with a binary search
ArraySQword_binarySearchFinds a signed qword in a sorted array of signed qwords with a binary search
ArrayReal8_binarySearchFinds an 8-byte real in a sorted array of 8-byte reals with a binary search
ArrayDqword_binarySearchFinds a dqword in a sorted array of dqwords with a binary search
ArraySDqword_binarySearchFinds a signed dqword in a sorted array of signed dqwords with a binary search
insertionSortFunctions for sorting an array with insertion sort
Functions
ArrayByte_insertionSortSorts an array of bytes with insertion sort
ArraySByte_insertionSortSorts an array of signed bytes with insertion sort
ArrayWord_insertionSortSorts an array of words with insertion sort
ArraySWord_insertionSortSorts an array of signed words with insertion sort
ArrayDword_insertionSortSorts an array of dwords or pointers with insertion sort
ArraySDword_insertionSortSorts an array of signed dwords or pointers with insertion sort
ArrayDwordMap_insertionSortSorts an array of key-value pairs of dwords or pointers with insertion sort
ArrayDword_bubbleSortSorts an array of dwords or pointers with bubble sort
ArraySDword_bubbleSortSorts an array of signed dwords or pointers with bubble sort
ArrayReal4_bubbleSortSorts an array of 4-byte reals with bubble sort
ArrayDword_maxFinds the maximum dword in an array
ArraySDword_maxFinds the maximum signed dword in an array
ArrayDword_minFinds the minimum dword in an array
ArraySDword_minFinds the minimum signed dword in an array
ArrayDword_sumFinds the sum of an array of signed or unsigned dwords
ArrayDword_sum_fastFinds the sum of an array of signed or unsigned dwords
ArrayReal4_sumFinds the sum of an array of 4-byte reals
ArrayReal4_sum_fastFinds the sum of an array of 4-byte reals

indexOf

Functions for finding the index of a value in an array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • first index of value in the array, or -1 if it’s not in the array
Summary
Functions
Array8_indexOfReturns the index of a byte in an array, or -1 if it’s not in the array
Array16_indexOfReturns the index of a word in an array, or -1 if it’s not in the array
Array32_indexOfReturns the index of a dword in an array, or -1 if it’s not in the array
Array64_indexOfReturns the index of a qword in an array, or -1 if it’s not in the array
Array128_indexOfReturns the index of a dqword in an array, or -1 if it’s not in the array

Functions

Array8_indexOf

Returns the index of a byte in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • first index of value in the array, or -1 if it’s not in the array

Array16_indexOf

Returns the index of a word in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • first index of value in the array, or -1 if it’s not in the array

Array32_indexOf

Returns the index of a dword in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • first index of value in the array, or -1 if it’s not in the array

Array64_indexOf

Returns the index of a qword in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • first index of value in the array, or -1 if it’s not in the array

Array128_indexOf

Returns the index of a dqword in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • first index of value in the array, or -1 if it’s not in the array

lastIndexOf

Functions for finding the last index of a value in an array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • last index of value in the array, or -1 if it’s not in the array
Summary
Functions
Array8_lastIndexOfReturns the last index of a byte in an array, or -1 if it’s not in the array
Array16_lastIndexOfReturns the last index of a word in an array, or -1 if it’s not in the array
Array32_lastIndexOfReturns the last index of a dword in an array, or -1 if it’s not in the array
Array64_lastIndexOfReturns the last index of a qword in an array, or -1 if it’s not in the array
Array128_lastIndexOfReturns the last index of a dqword in an array, or -1 if it’s not in the array

Functions

Array8_lastIndexOf

Returns the last index of a byte in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • last index of value in the array, or -1 if it’s not in the array

Array16_lastIndexOf

Returns the last index of a word in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • last index of value in the array, or -1 if it’s not in the array

Array32_lastIndexOf

Returns the last index of a dword in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • last index of value in the array, or -1 if it’s not in the array

Array64_lastIndexOf

Returns the last index of a qword in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • last index of value in the array, or -1 if it’s not in the array

Array128_lastIndexOf

Returns the last index of a dqword in an array, or -1 if it’s not in the array

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • last index of value in the array, or -1 if it’s not in the array

equals

Functions for checking equality of two arrays

Parameters

pArray0address of one array
pArray1address of the other array
lenlength of the arrays

Returns

  • index at which the arrays are first different, or -1 if the same
Summary
Functions
Array8_equalsChecks the equality of two arrays
Array16_equalsChecks the equality of two arrays
Array32_equalsChecks the equality of two arrays
Array64_equalsChecks the equality of two arrays
Array128_equalsChecks the equality of two arrays

Functions

Array8_equals

Checks the equality of two arrays

TODO: Make this more efficient.

Parameters

pArray0address of one array
pArray1address of the other array
lenlength of the arrays

Returns

  • index at which the arrays are first different, or -1 if the same

Array16_equals

Checks the equality of two arrays

TODO: Make this more efficient.

Parameters

pArray0address of one array
pArray1address of the other array
lenlength of the arrays

Returns

  • index at which the arrays are first different, or -1 if the same

Array32_equals

Checks the equality of two arrays

TODO: Make this more efficient.

Parameters

pArray0address of one array
pArray1address of the other array
lenlength of the arrays

Returns

  • index at which the arrays are first different, or -1 if the same

Array64_equals

Checks the equality of two arrays

TODO: Make this more efficient.

Parameters

pArray0address of one array
pArray1address of the other array
lenlength of the arrays

Returns

  • index at which the arrays are first different, or -1 if the same

Array128_equals

Checks the equality of two arrays

TODO: Make this more efficient.

Parameters

pArray0address of one array
pArray1address of the other array
lenlength of the arrays

Returns

  • index at which the arrays are first different, or -1 if the same

binarySearch

Functions for finding values in sorted arrays

Parameters

pArrayaddress of array
lenlength of array
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted
Summary
Functions
ArrayByte_binarySearchFinds a byte in a sorted array of bytes with a binary search
ArraySByte_binarySearchFinds a signed byte in a sorted array of signed bytes with a binary search
ArrayWord_binarySearchFinds a word in a sorted array of words with a binary search
ArraySWord_binarySearchFinds a signed word in a sorted array of signed words with a binary search
ArrayDword_binarySearchFinds a dword in a sorted array of dwords with a binary search
ArraySDword_binarySearchFinds a signed dword in a sorted array of signed dwords with a binary search
ArrayReal4_binarySearchFinds a 4-byte real in a sorted array of 4-byte reals with a binary search
ArrayQword_binarySearchFinds a qword in a sorted array of qwords with a binary search
ArraySQword_binarySearchFinds a signed qword in a sorted array of signed qwords with a binary search
ArrayReal8_binarySearchFinds an 8-byte real in a sorted array of 8-byte reals with a binary search
ArrayDqword_binarySearchFinds a dqword in a sorted array of dqwords with a binary search
ArraySDqword_binarySearchFinds a signed dqword in a sorted array of signed dqwords with a binary search

Functions

ArrayByte_binarySearch

Finds a byte in a sorted array of bytes with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of bytes)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArraySByte_binarySearch

Finds a signed byte in a sorted array of signed bytes with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of bytes)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArrayWord_binarySearch

Finds a word in a sorted array of words with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of words)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArraySWord_binarySearch

Finds a signed word in a sorted array of signed words with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of words)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArrayDword_binarySearch

Finds a dword in a sorted array of dwords with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of dwords)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArraySDword_binarySearch

Finds a signed dword in a sorted array of signed dwords with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of dwords)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArrayReal4_binarySearch

Finds a 4-byte real in a sorted array of 4-byte reals with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of dwords)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArrayQword_binarySearch

Finds a qword in a sorted array of qwords with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of qwords)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArraySQword_binarySearch

Finds a signed qword in a sorted array of signed qwords with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of qwords)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArrayReal8_binarySearch

Finds an 8-byte real in a sorted array of 8-byte reals with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of qwords)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArrayDqword_binarySearch

Finds a dqword in a sorted array of dqwords with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of dqwords)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

ArraySDqword_binarySearch

Finds a signed dqword in a sorted array of signed dqwords with a binary search

Parameters

pArrayaddress of array
lenlength of array (number of dqwords)
valuevalue for which to search

Returns

  • index of value, or if not found, (-index-1), where index is where value would be inserted to keep the array sorted

insertionSort

Functions for sorting an array with insertion sort

Parameters

pArrayaddress of array
lenlength of array
Summary
Functions
ArrayByte_insertionSortSorts an array of bytes with insertion sort
ArraySByte_insertionSortSorts an array of signed bytes with insertion sort
ArrayWord_insertionSortSorts an array of words with insertion sort
ArraySWord_insertionSortSorts an array of signed words with insertion sort
ArrayDword_insertionSortSorts an array of dwords or pointers with insertion sort
ArraySDword_insertionSortSorts an array of signed dwords or pointers with insertion sort
ArrayDwordMap_insertionSortSorts an array of key-value pairs of dwords or pointers with insertion sort
ArrayDword_bubbleSortSorts an array of dwords or pointers with bubble sort
ArraySDword_bubbleSortSorts an array of signed dwords or pointers with bubble sort
ArrayReal4_bubbleSortSorts an array of 4-byte reals with bubble sort
ArrayDword_maxFinds the maximum dword in an array
ArraySDword_maxFinds the maximum signed dword in an array
ArrayDword_minFinds the minimum dword in an array
ArraySDword_minFinds the minimum signed dword in an array
ArrayDword_sumFinds the sum of an array of signed or unsigned dwords
ArrayDword_sum_fastFinds the sum of an array of signed or unsigned dwords
ArrayReal4_sumFinds the sum of an array of 4-byte reals
ArrayReal4_sum_fastFinds the sum of an array of 4-byte reals

Functions

ArrayByte_insertionSort

Sorts an array of bytes with insertion sort

Parameters

pArrayaddress of array
lenlength of array (number of bytes)

ArraySByte_insertionSort

Sorts an array of signed bytes with insertion sort

Parameters

pArrayaddress of array
lenlength of array (number of bytes)

ArrayWord_insertionSort

Sorts an array of words with insertion sort

Parameters

pArrayaddress of array
lenlength of array (number of words)

ArraySWord_insertionSort

Sorts an array of signed words with insertion sort

Parameters

pArrayaddress of array
lenlength of array (number of words)

ArrayDword_insertionSort

Sorts an array of dwords or pointers with insertion sort

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

ArraySDword_insertionSort

Sorts an array of signed dwords or pointers with insertion sort

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

ArrayDwordMap_insertionSort

Sorts an array of key-value pairs of dwords or pointers with insertion sort

Parameters

pArrayaddress of array
lenlength of array (number of pairs of dwords)

ArrayDword_bubbleSort

Sorts an array of dwords or pointers with bubble sort

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

ArraySDword_bubbleSort

Sorts an array of signed dwords or pointers with bubble sort

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

ArrayReal4_bubbleSort

Sorts an array of 4-byte reals with bubble sort

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

ArrayDword_max

Finds the maximum dword in an array

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

Returns

  • the maximum value

ArraySDword_max

Finds the maximum signed dword in an array

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

Returns

  • the maximum value

ArrayDword_min

Finds the minimum dword in an array

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

Returns

  • the minimum value

ArraySDword_min

Finds the minimum signed dword in an array

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

Returns

  • the minimum value

ArrayDword_sum

Finds the sum of an array of signed or unsigned dwords

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

Returns

  • the sum

ArrayDword_sum_fast

Finds the sum of an array of signed or unsigned dwords

The array is preferably aligned to 16 bytes, or even 64 bytes, and with a multiple of 16 entries.

NOTE: Changes values in xmm0, xmm1, xmm2, and xmm3

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

Returns

  • the sum

ArrayReal4_sum

Finds the sum of an array of 4-byte reals

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

Returns

  • the sum

ArrayReal4_sum_fast

Finds the sum of an array of 4-byte reals

The array is preferably aligned to 16 bytes, or even 64 bytes, and with a multiple of 16 entries.

NOTE: Changes values in xmm0, xmm1, xmm2, and xmm3

Parameters

pArrayaddress of array
lenlength of array (number of dwords)

Returns

  • the sum
This file defines the library for common data types and algorithms of PwnOS.
This file defines structures and constants for the library of common data types and algorithms of PwnOS.