Carry, borrow and overflow for 16-bit word maths

hippy

Technical Support
Staff member
The following determine how to calculate if there has been a carry, borrow or overflow when performing 16-bit word maths.

The 'carry', 'borrow' and 'overflow' variables are set to 1 when those have occurred, are set to 0 if not.

w1 = w2 + w3
carry = w1 Max w2 - w2 Max 1

w1 = w2 - w3
borrow = w1 Min w2 - w2 Max 1

w1 = w2 * w3
overflow = w2 ** w3 Max 1
 
Top