c: Fix shruw and mulhuw
authorDavid Schleef <ds@schleef.org>
Wed, 8 Jul 2009 01:56:37 +0000 (18:56 -0700)
committerDavid Schleef <ds@schleef.org>
Tue, 14 Jul 2009 17:56:37 +0000 (10:56 -0700)
orc/opcodes.h

index 0c74aaf..2e0e738 100644 (file)
@@ -43,11 +43,11 @@ BINARY_SW(minsw, "ORC_MIN(%s, %s)")
 BINARY_UW(minuw, "ORC_MIN(%s, %s)")
 BINARY_SW(mullw, "(%s * %s) & 0xffff")
 BINARY_SW(mulhsw, "(%s * %s) >> 16")
-BINARY_UW(mulhuw, "(%s * %s) >> 16")
+BINARY_UW(mulhuw, "((uint32_t)((uint16_t)%s) * (uint32_t)((uint16_t)%s)) >> 16")
 BINARY_SW(orw, "%s | %s")
 BINARY_SW(shlw, "%s << %s")
 BINARY_SW(shrsw, "%s >> %s")
-BINARY_UW(shruw, "%s >> %s")
+BINARY_UW(shruw, "((uint16_t)%s) >> %s")
 UNARY_SW(signw, "ORC_CLAMP(%s,-1,1)")
 BINARY_SW(subw, "%s - %s")
 BINARY_SW(subssw, "ORC_CLAMP_SW(%s - %s)")