negate

Negates a 16-bit integer or fractional value returning a 16-bit result. Returns 0x7FFF for an input of 0x8000.

Assumptions

OMR's SA bit was set to 1 at least three cycles before this code, that is, saturation on data ALU results enabled.

Prototype

  Word16 negate(Word16 svar1)

    
Example

  int result, s1 = 0xE000;  /*  - 0.25    */

  result = negate(s1);

  // Expected value of result: 0x2000 = 0.25