This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch : M32C] Fix sim for carry flag handling


Hi,
The following patch fixes the handling of the carry flag when the SUB
and SBB instructions are executed. The MATH_OP macro in r8c.opc 
has a an extra parameter 'carryrel' to handle the relative carry in 
case of result '>=' while the m32c.opc only handles cases where 
result is '>'. This causes the M32C simulator to only handle the ADD 
instructions correctly but it fails to set the carry flag for SUB 
when the result of a subtraction is 0. This flag should be set as per
the manual and is being correctly handled in R8C and M16C. 
This patch seems to fix our testcase, but causes 2 extra failures for
M32C and M32CM in DejaGnu testsuite for test case 'pointer-arith-4.c'
which performs pointer subtraction. Is the result here expected to be
zero without any carry flag or side effects?

gcc.sum file error log ->
FAIL: gcc.dg/pointer-arith-4.c  (test for errors, line 40)

Please comment.
Regards,
Kaushik Phatak
www.kpitgnutools.com

=======================Start of Patch================================

Changelog
2010-01-19  Kaushik Phatak <kaushik.phatak@kpitcummins.com>
	* m32c/m32c.opc (decode_m32c) : Fix MATH_OP for carry in SUB insn

diff -rNup scr.orig/sim/m32c/m32c.opc src/sim/m32c/m32c.opc

--- scr.orig/sim/m32c/m32c.opc	2009-01-14 16:23:07.000000000 +0530
+++ src/sim/m32c/m32c.opc	2010-01-18 15:01:41.000000000 +0530
@@ -125,7 +125,8 @@ prefix (src_allowed, dest_allowed, index
   mb = sign_ext (s, dc.bytes * 8); \
   v = ma op mb op c; \
   tprintf("%d " #op " %d " #op " %d = %d\n", ma, mb, c, v); \
-  set_oszc (v, dc.bytes, ll > ((1 op 1) ? b2mask[dc.bytes] : 0)); \
+  set_oszc (v, dc.bytes, (#op=="+") ? ll > ((1 op 1) ? \
+  b2mask[dc.bytes] : 0) : ll >= ((1 op 1) ? b2mask[dc.bytes] : 0) ); \
   put_dest (dc, v); \
 }
 
=========================End Of Patch================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]