This is not written in the assembly ... A memory comparison is valid if all memory is filled with array elements without spaces. This usually works if
1) All array memory is filled with data without spaces (a gap may contain garbage and cause a false negative result).
1.1. this should be done using the packed array keyword if the compiler doesn't ignore it
1.2 this should happen if SizeOf (A [1]) is 2,4,8,16, etc.
But itβs better to clean it with unit tests, using FillChar with different templates - they will simulate garbage, then manually fill the array elements with the appropriate values, and then check with CompareMem that the elements destroyed all the pre-filled garbage.
2) The array elements contain only simple value types, not reference types.
Char, integer, double, short strings, arrays of a fixed size or records from them are simple types.
All other lines, pointers, objects, interfaces, dynamic and open arrays - just point to external data and can not be compared "by memory"
You can read about http://docwiki.embarcadero.com/Libraries/XE2/en/System.Finalize for more tips. An assembly-based implementation of procedures / functions would also be a good topic, since it would cover binary representations of different Delphi data types.
source share