Пойдет ?
C:=C + (abs(word_to_int(оттуда - M)) mod 16#10000);