This is not written in assembly... Comparing memory is valid if all the memory is filled with array items without gaps. Generally it would work if
1) All array memory is filled with data without gaps (gap may contain garbage and cause false negative).
1.1. this should be enforced by packed array
keyword, if compiler would not ignore it
1.2 this should happen if SizeOf(A[1]) is 2,4,8,16 etc
But you better cover this by unit tests using FillChar with different patterns - they would imitate garbage, then manual filling of array elements with matching values, then checking with CompareMem that elements wiped all the pre-filled garbage.
2) Array elements only contain simple value types, not reference types.
Char, integer, double, short string, fixed-size array or record made of those - are simple types.
All other strings, pointers, objects, interfaces, dynamic and open arrays - are merely pointers to the external data, and can not be compared "by memory"
You may read about http://docwiki.embarcadero.com/Libraries/XE2/en/System.Finalize for more hints. Assembler implementation of procedures/functions would also be good topic, as it would cover binary representations of different Delphi data types