PDA

View Full Version : Exclusive Or not working...


PJE
12-20-04, 04:38 PM
I've been wrestling with StatiC all day and the program which works in Small-C does not work in StatiC...

I found that exclusive or (~) does not work correctly.

i = 5
j = 6
k = i ~ j

produces the following asm code:

MOVE #5,X:i
MOVE #6,X:j
MOVE X:i,X0
MOVE X0,X:k

Shouldn't there be an EOR somewhere?

MOVE #5,X:i
MOVE #6,X:j
MOVE X:i,X0
{EOR here}
MOVE X0,X:k

Regards,

PJE

petegray
12-20-04, 08:00 PM
You're right. I missed this one. So did a dozen beta testers.
Fortunately, it looks like it only occurs with the XOR operator "~".

I'll email you the fix this evening.

Regards,
-Pete.

PJE
12-21-04, 08:50 AM
Thanks Pete!

Now that's what I call service...

Anyway, on to the next problem. ;)

This code snippet does not work:

INptr=7 ; Added for debug
i=0
BCCin=0
while (i{INptr) ;{ Replaced < for display
BCCin=BCCin~U60in[i]
i=i+1
{Added Print BCCin here}
endwhile

In the above case the BCC was never printed.

If I change this to:

i=0
BCCin=0
while (i<7)
...
endwhile

Then the code works fine.

Looking at the assembler I get for the first case :

MOVE X:i,Y0
MOVE X:INptr,X0
CMP Y0,X0
JGE L17

and for the second...:

MOVE X:i,X0
CMP #7,X0
JGE L17

HOWEVER, If I change it to:

while (i>=INptr)

all is well... AHAH!

It looks like Y0 and X0 are swapped as Y0=i and X0=INptr (7) in the fisrt case. Giving CMP i,#7.

Thoughts.

Regards,

PJE

petegray
12-21-04, 10:15 AM
No problem.

This looks like one of the optimization rules has incorrectly swapped the position of the variables in the compare. I'll investigate and get the fix to you shortly.

Regards,
-Pete.

petegray
12-21-04, 10:06 PM
PJE,

FYI, I emailed the fix directly to you this evening.

Regards,
-Pete.

PJE
01-02-05, 10:35 AM
Thanks Pete,

I'll try it out when I get back to work and can get on the target hardware.

PJE