Performing arithmetic function on memory contents