It’s time for a puzzle again! (submitted by sheepmaster)
Calculate in x86 assembly language the arithmetic mean (a+b)/2 of two signed integers a and b. If you think this is trivial, consider the following edge cases: a = b = 0x7FFFFFFF and a = 0x7FFFFFFF, b = 0x80000000.
Again, the standard rules apply: a and b are in general purpose registers of your choice, the result can be in any register, and any register can be overwritten.
Oh, and by the way, using larger data types isn’t allowed either (that would make things too easy, wouldn’t it?).