abstracted code emit for COMPARE into helper function