From: Arne.Venstad@DELAB.SINTEF.no (Arne Venstad)
Newsgroups: comp.sys.mac.programmer
Subject: THINK C 5.04 bug, or is it me?
Date: 8 Jan 93 09:40:06 GMT
Followup-To: comp.sys.mac.programmer
Organization: SINTEF DELAB

Dear net friends,

After going from THINK C 4.05 to THINK C 5.04 my XFCN started to execute
erroneously. Parts of my code:

...
typedef struct irow {
	long iPtr;
	short length;
} Row;
...
    Row *source,*target;
    ...
    source=...;
    target=...;
    ...
				while (source!=target)  /* As somebody may guess, this is an attempt to
*/
					 *target--=*target;    /* make a block move on overlapping areas. */
    ...

When disassembling this I get respectively for
THINK C 4.05:
=============
+0698  0066A51A  *BRA.S      UPDATEIN+06AA              ; 0066A52C   | 6010
+069A  0066A51C   MOVEA.L    -$003C(A6),A0                           | 206E
FFC4
+069E  0066A520   SUBQ.L     #$6,-$003C(A6)                          | 5DAE
FFC4
+06A2  0066A524   MOVEA.L    -$003C(A6),A1                           | 226E
FFC4
+06A6  0066A528   MOVE.L     (A1)+,(A0)+                             | 20D9
+06A8  0066A52A   MOVE.W     (A1)+,(A0)+                             | 30D9
+06AA  0066A52C   MOVE.L     -$0038(A6),D0                           | 202E
FFC8
+06AE  0066A530   CMP.L      -$003C(A6),D0                           | B0AE
FFC4
+06B2  0066A534   BNE.S      UPDATEIN+069A              ; 0066A51C   | 66E6
+06B4  0066A536   MOVEA.L    -$0038(A6),A0                           | 206E
FFC8
+06B8  0066A53A   MOVE.L     -$0094(A6),(A0)                         | 20AE
FF6C
+06BC  0066A53E   MOVEA.L    -$0038(A6),A0                           | 206E
FFC8
+06C0  0066A542   MOVE.W     -$009E(A6),$0004(A0)                    | 316E
FF62 0004
+06C6  0066A548   BRA        UPDATEIN+076E              ; 0066A5F0   | 6000
00A6

which seems to work ok.

For
THINK C 5.04:
=============
+37AE  0072F30E  *BRA.S      'XFCN 0190 0816 checI+37C0 ; 0072F320   | 6010
+37B0  0072F310   MOVEA.L    -$0082(A6),A0                           | 206E
FF7E
+37B4  0072F314   SUBQ.L     #$6,-$0082(A6)                          | 5DAE
FF7E
+37B8  0072F318   MOVE.L     (A0),(A0)                               | 2090
+37BA  0072F31A   MOVE.W     $0004(A0),$0004(A0)                     | 3168
0004 0004
+37C0  0072F320   MOVE.L     -$00D6(A6),D0                           | 202E
FF2A
+37C4  0072F324   CMP.L      -$0082(A6),D0                           | B0AE
FF7E
+37C8  0072F328   BNE.S      'XFCN 0190 0816 checI+37B0 ; 0072F310   | 66E6
+37CA  0072F32A   MOVEA.L    -$00D6(A6),A0                           | 206E
FF2A
+37CE  0072F32E   MOVE.L     -$00DA(A6),(A0)                         | 20AE
FF26
+37D2  0072F332   MOVE.W     -$00E4(A6),$0004(A0)                    | 316E
FF1C 0004
+37D8  0072F338   BRA        'XFCN 0190 0816 checI+385A ; 0072F3BA   | 6000
0080

This code does not work in certain cases.

I am neither an C expert nor an MC68 ASM expert, so I am not able to
resolve
this myself. So if anybody could tell what is wrong and what to do about
it,
I would be very glad!

Thanks,

Arne Venstad    E-mail: Arne.Venstad@delab.sintef.no
SINTEF DELAB
N-7034 Trondheim,
Norway.
Newsgroups: comp.sys.mac.programmer