|
|
View previous topic :: View next topic |
Author |
Message |
GregReadUK
Joined: 24 Jan 2011 Posts: 6 Location: Kent, UK
|
Error/Bug in == and != operators in 4.117 compiler on 24F? |
Posted: Mon Jan 24, 2011 4:43 am |
|
|
Hi Folks.
I am encountering a major problem in the latest compiler version 4.117. The != and == operators don't work as expected, e.g. 0 != 0.
Only tested on DEVICE:PIC24FJ64GA004
COMPILER VERSION:4.117
Can anyone offer any advice, see code example below.
Many Thanks,
Greg
Code: |
#include <24FJ64GA004.h>
#device *=16
/* DEBUG FUSES THAT CAUSE VERIFICATION ERROR */
//#fuses DEBUG
//#device icd=true
#fuses NOWDT
#fuses ICSP1
#fuses NOWRT
#fuses NOPROTECT
#fuses NOJTAG
#fuses NOCKSFSM // NO FAIL SAFE CLOCK MONITOR
#fuses OSCIO // OSC 2 IS A GENERAL PURPOSE INPUT
#fuses NOIESO // THIS CAUSES IT TO BOOT OFF THE INTERNAL CRYSTAL IF EXTERNAL FAILED
//#fuses IESO
#fuses HS // USE EXTERNAL HIGH SPEED OSCILLATOR
#fuses PR // RUN OSCILLATOR AT HS OSCILLATOR SPEED
// #use delay(clock=22118400)
#use delay(clock=25M)
// I2C definition for clock
//#USE I2C(MASTER, I2C1, FORCE_HW, RESTART_WDT)
#USE I2C(MASTER, SCL=PIN_B6, SDA=PIN_B5, RESTART_WDT)
#use rs232(baud=115200,parity=N,bits=8,errors,XMIT=PIN_B8,RCV=PIN_B13)
void Debug_putc(BYTE Data)
{
putc(Data);
}
unsigned int8 ui1 = 0;
unsigned int8 ui2 = 0;
void main()
{
int8 si1 = 0;
int8 si2 = 0;
unsigned int8 lui1 = 0;
unsigned int8 lui2 = 0;
unsigned int16 ui161 = 0;
unsigned int16 ui162 = 0;
unsigned int32 ui321 = 0;
unsigned int32 ui322 = 0;
printf(Debug_putc, "\r\nWhat are the != and == operators doing?\r\n");
printf(Debug_putc, "DEVICE:%s\r\n", getenv("DEVICE"));
printf(Debug_putc, "COMPILER VERSION:%s\r\n", getenv("VERSION_STRING"));
if (ui1 != ui2)
printf(Debug_putc, "ui1(%u) != ui2(%u)\r\n", ui1, ui2);
else
printf(Debug_putc, "ui1(%u) == ui2(%u)\r\n", ui1, ui2);
if (ui1 == ui2)
printf(Debug_putc, "ui1(%u) == ui2(%u)\r\n", ui1, ui2);
else
printf(Debug_putc, "ui1(%u) != ui2(%u)\r\n", ui1, ui2);
if (si1 != si2)
printf(Debug_putc, "si1(%u) != si2(%u)\r\n", si1, si2);
else
printf(Debug_putc, "si1(%u) == si2(%u)\r\n", si1, si2);
if (lui1 != lui2)
printf(Debug_putc, "lui1(%u) != lui2(%u)\r\n", lui1, lui2);
else
printf(Debug_putc, "lui1(%u) == lui2(%u)\r\n", lui1, lui2);
if (ui161 != ui162)
printf(Debug_putc, "ui161(%u) != ui162(%u)\r\n", ui161, ui162);
else
printf(Debug_putc, "ui161(%u) == ui162(%u)\r\n", ui161, ui162);
if (ui321 != ui322)
printf(Debug_putc, "ui321(%u) != ui322(%u)\r\n", ui321, ui322);
else
printf(Debug_putc, "ui321(%u) == ui322(%u)\r\n", ui321, ui322);
}
// Output produced -- Fails for 32bit, 16 bit and 8 bit ints
// What are the != and == operators doing?
// DEVICE:PIC24FJ64GA004
// COMPILER VERSION:4.117
// ui1(0) != ui2(0)
// ui1(0) != ui2(0)
// si1(0) != si2(0)
// lui1(0) != lui2(0)
// ui161(0) != ui162(0)
// ui321(0) != ui322(0) |
|
|
|
GregReadUK
Joined: 24 Jan 2011 Posts: 6 Location: Kent, UK
|
Fixed in 4.118 |
Posted: Mon Jan 24, 2011 4:58 am |
|
|
Just tried 4.118 and it is fixed. thanks.
Results are now..
What are the != and == operators doing?
DEVICE:PIC24FJ64GA004
COMPILER VERSION:4.118
ui1(0) == ui2(0)
ui1(0) == ui2(0)
si1(0) == si2(0)
lui1(0) == lui2(0)
ui161(0) == ui162(0)
ui321(0) == ui322(0) |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Jan 24, 2011 8:48 am |
|
|
Quote: | Just tried 4.118 and it is fixed. thanks. |
Good, unfortunately there are sufficient unfixed bugs, like below, new in V4.114, reported Nov 01, 2010
http://www.ccsinfo.com/forum/viewtopic.php?t=44256
Or a double bug, reported 7 month ago, still present in V4.118
Code: | #include <24FJ128GA106.h>
#use delay(clock=16000000,RESTART_WDT)
#use rs232(UART1,baud=38400,parity=N,bits=8)
#case
typedef struct {
unsigned int8 b1,b2,b3,b4;
} BS, *PBS;
unsigned int32 mm = 16;
unsigned int32 nn = 1024;
BS bs = {1,2,3,4};
PBS pbs = &bs;
void sub1(void)
{
mm += nn/256; // Wrong result due to register overwrite
/*
0024A: MOV.B 805,W0L
0024C: MOV.B 806,W0L
0024E: MOV.B W0L,1
00250: MOV.B 807,W0L
00252: MOV W0,W1
00254: CLR.B 3
00256: ADD 800
00258: MOV W1,W0
0025A: ADDC 802,W0
0025C: MOV W0,802
*/
mm *= pbs->b3;
/*
0025E: MOV #2,W0
00260: ADD 808,W0
00262: MOV W0,W4
00264: MOV.B [W4],W0L
00266: MOV 802,W1
00268: MOV.B W0L,W2L
0026A: CLR.B 5
0026C: MOV #0,W3
0026E: MOV [--W15],W0 // Stack-Error
00270: CALL 200
00274: MOV W0,800
00276: MOV W1,802
*/
}
void main(void)
{
sub1();
while (1);
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|