Topic : RC51 - optimisation - signed char comparision

Forum : 8051

Original Post
Post Information Post
January 18, 2008 - 7:59pm
Guest

signed char AbsS8(signed char n)
{
return (n == -128) ? 127 : n;
}

makes the following:

WIN32 RC51 COMPILER V03.03.43, COMPILATION OF MODULE T1
OBJECT MODULE PLACED IN c:\spj1\swr\math\arith\ride\\obj_large\t1.obj
COMPILER INVOKED BY: RC51.EXE C:\SPJ1\SWR\MATH\ARITH\SRC\T1.C OBJECT(C:\SPJ1\SWR
-\MATH\ARITH\RIDE\\OBJ_LARGE\T1.OBJ) PIN(C:\CSIAPPS\RIDE\INC;C:\CSIA
-PPS\RIDE\INC\51;..\SRC;C:\SPJ1\SWR\TINY1\PUBLIC) PIN(C:\CSIAPPS\RID
-E\INC\51\CYGNAL\) NOAM PR(C:\SPJ1\SWR\MATH\ARITH\RIDE\\LST\T1.LST)
-CD SB OE(1) LA NOIP FP(NOFLOAT) PW(80) DF(TOOL_IS_RIDE_8051,TARGET_
-IS_LARGE_LIB) NOIS NOGENERIC UNSIGNEDCHAR ET(CHAR)

; FUNCTION _AbsS8 (BEGIN)
; Register R7 is assigned to parameter n
; SOURCE LINE # 3
0000 EF MOV A,R7
0001 33 RLC A
0002 95E0 SUBB A,ACC
0004 B4FF05 CJNE A,#0FFH,?NXT1
0007 BF8002 CJNE R7,#080H,?NXT1
000A 7F7F MOV R7,#07FH
000C ?NXT1:
; SOURCE LINE # 4
000C 22 RET

; FUNCTION _AbsS8 (END)

Lines 0001 - 0004 do nothing.

regards Steven Pruzina

Replies
Post Information Post
+1
0
-1
January 21, 2008 - 5:08pm
Guest

You're right, the optimization is not done when the constant is a negative char. To be done. Thanks.

+1
0
-1
January 31, 2008 - 2:52pm
Guest

Done now. Will be available in the next release.