Truncated match.
PICList
Thread
'"New" optimizing PIC C-compiler:'
1999\06\01@083911
by
Anders Widgren
|
After 7 years CC5X still remains the best optimizing PIC C-compiler! CC5X supports both low end (12-bit core 16C5X/12CXX) and midrange (14-bit core 16CXX) PICs. CC5X ver 3.0 that was just released has a lot of new features including 1, 8, 16, 24 and 32 bit variables, signed and unsigned. The price for CC5X is only $120 (reduced), $280 (standard) or $550 (extended)! When I compared it to MPC, MPLAB-C, HiTech, CCS and IAR they all generated at least 25% more code plus usually required several times as much RAM space. CC5X is stable! I have been using CC5X for all my PIC projects since 1992 and during that time I have only found a couple of bugs (which have all been corrected). Check out http://www.bknd.com. Possible to download working demos! (Limitations of the free demo: Max code size=1024 instructions, only basic optimization, variables = max 16 bit.)
-AW
=============================================
Anders Widgren, GEWA R&D, GEWAB Elmekaniska AB
Visiting addr: Dag Hammarskjšlds vŠg 34A, Uppsala, Sweden
Mail addr: Uppsala Science Park, SE-751 83 Uppsala, Sweden
Phone: +46-18 512440, Fax: +46-18 512443
Email: spam_OUTanders.widgrenTakeThisOuT
gewab.se www: http://www.gewab.se
1999\06\01@091914
by
Andy Kunz
>demos! (Limitations of the free demo: Max code size=1024 instructions, only
>basic optimization, variables = max 16 bit.)
That's a stupid limitation. If somebody wants to buy a compiler, one of
the biggest points in the evaluation is optimization.
I'm still VERY happy with my HiTech compiler.
Andy
==================================================================
Montana Design Tech Support - http://www.montanadesign.com
==================================================================
1999\06\01@093409
by
Lawrence Lile
|
I'll try it. it's gotta be better than CCS.
-----Original Message-----
From: Anders Widgren <.....anders.widgrenKILLspam
@spam@GEWAB.SE>
To: PICLIST
KILLspamMITVMA.MIT.EDU <.....PICLISTKILLspam
.....MITVMA.MIT.EDU>
Date: Tuesday, June 01, 1999 7:39 AM
Subject: "New" optimizing PIC C-compiler:
After 7 years CC5X still remains the best optimizing PIC C-compiler! CC5X
supports both low end (12-bit core 16C5X/12CXX) and midrange (14-bit core
16CXX) PICs. CC5X ver 3.0 that was just released has a lot of new features
including 1, 8, 16, 24 and 32 bit variables, signed and unsigned. The price
for CC5X is only $120 (reduced), $280 (standard) or $550 (extended)! When I
compared it to MPC, MPLAB-C, HiTech, CCS and IAR they all generated at least
25% more code plus usually required several times as much RAM space. CC5X is
stable! I have been using CC5X for all my PIC projects since 1992 and during
that time I have only found a couple of bugs (which have all been
corrected). Check out http://www.bknd.com. Possible to download working
demos! (Limitations of the free demo: Max code size=1024 instructions, only
basic optimization, variables = max 16 bit.)
-AW
=============================================
Anders Widgren, GEWA R&D, GEWAB Elmekaniska AB
Visiting addr: Dag Hammarskjvlds vdg 34A, Uppsala, Sweden
Mail addr: Uppsala Science Park, SE-751 83 Uppsala, Sweden
Phone: +46-18 512440, Fax: +46-18 512443
Email: EraseMEanders.widgrenspam_OUT
TakeThisOuTgewab.se www: http://www.gewab.se
1999\06\03@024120
by
Anders Widgren
Walter,
somehow I don't think I'm going to convince YOU... :-) Anyway, I believe the d
emo comes with some example files...
-Anders
-----Original Message-----
From: Walter Banks [SMTP:walter
spam_OUTbytecraft.com]
Sent: Wednesday, June 02, 1999 1:24 PM
To: Anders Widgren
Subject: Re: "New" optimizing PIC C-compiler:
Could you provide me with a source and HEX of a single non trival
application
that shows off CC5X as having the kind of code generation that you are
seeing.
Walter Banks
1999\06\03@032349
by
Tjaart van der Walt
Anders Widgren wrote:
>
> Walter,
> somehow I don't think I'm going to convince YOU... :-) Anyway, I believe the
demo comes with some example files...
>
> -Anders
> {Original Message removed}
1999\06\03@182610
by
Dennis Plunkett
At 09:39 3/06/99 +0200, you wrote:
>Anders Widgren wrote:
>>
>> Walter,
>> somehow I don't think I'm going to convince YOU... :-) Anyway, I
believe the demo comes with some example files...
>>
>> -Anders
>> {Original Message removed}
1999\06\07@051154
by
Anders Widgren
|
part 0 19284 bytes
The last time I did a more serious comparison between PIC C-compilers was in 1995. The problem was to come up with code that would work under several of these rather simple C-compilers. It would be much more interesting to use code from an actual "typical" project. I might do something like that during the summer. The code below compiled by CC5X for a 16C67 device resulted in 238 instructions and 13 RAM bytes. How much code does your compiler generate for the same code? Of course, in a real project I would probably use a look-up table instead of a case structure. (CC5X has a skip() instructions that automatically generates checked look-up tables.)
-AW
/******************************************************************************
c_benchm.c "Nonsense code" for test of C-compilers.
Rev. history : 950529 First version
950726 Version modified to be as close as possible to
a real program. (About the same percentage of
the different statements as in my real software.)
990607 Added more local variables. Changed from
1 K device 16C71 to 8 K 16C67.
The following command line was used (from within CodeWright):
CC5X %y.c -O%x -CA%y.cod +%y.par > %y.err
c_benchm.par contained the following compiler options:
-AEOKG
-wU
-Q
-L120,60
-AJ8+6+10
-fINHX8M
-a
-V
c_benchm.asm is listed after the source code. This was the resulting compiler output
(.err, .fcs and .var files):
CC5X Version 2.1I, Copyright (c) B. Knudsen Data, Norway 1992-1997, No. 381
C_BENCHM.c:
Chip = 16C67
RAM : -------- -------- -------- -------- ======== ===..*** ******** ********
40h: ******** ******** ******** ******** ******** ******** ******** ********
80h: -------- -------- -------- -------- ******** ******** ******** ********
C0h: ******** ******** ******** ******** ******** ******** -------- --------
100h: -------- -------- ******** ******** ******** ******** ******** ********
140h: ******** ******** ******** ******** ******** ******** -------- --------
180h: -------- -------- ******** ******** ******** ******** ******** ********
1C0h: ******** ******** ******** ******** ******** ******** -------- --------
File 'C:\_c_cc5x\PROJECTS\Diverse\C_BENCHM\CC5X\C_BENCHM.fcs'
Optimizing - removed 12 instructions (-4 %)
File 'C:\_c_cc5x\PROJECTS\Diverse\C_BENCHM\CC5X\C_BENCHM.var'
File 'C:\_c_cc5x\PROJECTS\Diverse\C_BENCHM\CC5X\C_BENCHM.asm'
File 'C:\_c_cc5x\PROJECTS\Diverse\C_BENCHM\CC5X\C_BENCHM.lst'
File 'C:\_c_cc5x\PROJECTS\Diverse\C_BENCHM\CC5X\C_BENCHM.cod'
Codepage 0 has 238 word(s) : 11 %
Codepage 1 has 0 word(s) : 0 %
Codepage 2 has 0 word(s) : 0 %
Codepage 3 has 0 word(s) : 0 %
File 'C:\_c_cc5x\PROJECTS\Diverse\C_BENCHM\CC5X\C_BENCHM.hex'
Total of 238 instructions (2 %)
CC5X Version 2.1I, Copyright (c) B. Knudsen Data.
* FUNCTION CALL STRUCTURE
F: TestSwitch :#2 : p0
F: TestIf :#2 : p0
F: TestWhile :#2 : p0
TestIf : #2 : p0 -> p0
TestSwitch : #2 : p0 -> p0
F: TestDo :#2 : p0
TestWhile : #2 : p0 -> p0
F: TestFor :#1 : p0 <- p0
TestDo : #2 : p0 -> p0
F: main :#0 : p0
TestSwitch : #2 : p0 -> p0
TestIf : #2 : p0 -> p0
TestWhile : #2 : p0 -> p0
TestDo : #2 : p0 -> p0
TestFor : #1 : p0 -> p0
L0 main
L1 TestSwitch
L1 TestIf
L1 TestWhile
L2 TestIf
L2 TestSwitch
L1 TestDo
L2 TestWhile
L3 TestIf
L3 TestSwitch
L1 TestFor
L2 TestDo
L3 TestWhile
L4 TestIf
L4 TestSwitch
CC5X Version 2.1I, Copyright (c) B. Knudsen Data.
* VARIABLE LIST FILE
Source 'C_BENCHM.c'
Chip = 16C67
=== Sorted by address ===
L [0] 0x020 : 2: Local_3
L [0] 0x021 : 6: Local_2
L [0] 0x022 : 4: Local
L [0] 0x023 : 8: Parameter_3
L [0] 0x024 : 5: Local1_3
L [0] 0x025 : 2: Local2_3
L [0] 0x026 : 7: Parameter
L [0] 0x026 : 13: Parameter_2
L [0] 0x027 : 4: Local1_2
L [0] 0x027 : 4: Local1
L [0] 0x028 : 2: Local2
L [0] 0x028 : 3: Local2_2
L [0] 0x029 : 3: Local3
L [0] 0x02A : 0: Local4
G [0] 0x02B : 28: Global_A
G [0] 0x02C : 25: Global_B
******************************************************************************/
#include "16C67.h"
char Global_A,Global_B;
char TestSwitch(char Parameter)
/******************************************************************************
Test of the switch statement.
******************************************************************************/
{
char Local1,Local2;
Local2=Parameter+'A';
Local1=Parameter+'A';
Local1+=Local2;
switch(Local1)
{
case 'A': Global_B+=6;break;
case 'B': Global_B=Parameter+5;Global_A=5;break;
case 'C': Global_B=Parameter+2;Global_A+=2;break;
case 'D': Global_B=Parameter-10;return '4';
case 'E': Global_B=Parameter+5;return Global_A;
case 'F': Global_A-=9;break;
case 'G': Global_A=35;break;
}
return Local1;
}
void TestIf(char Parameter)
/******************************************************************************
Test of the if statement.
******************************************************************************/
{
char Local1,Local2,Local3,Local4;
Local1=Parameter+5;
Local2=Global_A;
Local3=Local1+Local2;
if(Local1>=5 && Parameter==1)
{
Global_A=Parameter+2;
Parameter=12;
}
else if(Local2<=5 && Parameter==2)
{
Parameter+=4;
Global_A=2;
}
if(Local3==5 && Parameter==3)
{
Global_A-=1;
}
else if(Local1>5 || Parameter==4)
{
Global_A&=Global_A;
Parameter++;
}
else if(Local2<5 || Parameter==5)
{
Global_B--;
}
if(Local3==5)
Global_B=Parameter+10;
else
Global_B=Parameter+20;
}
char TestWhile(char Parameter)
/******************************************************************************
Test of the while statement.
******************************************************************************/
{
char Local1,Local2;
TestIf(Global_B);
Local1=Parameter+5;
Local2=TestSwitch(Local1);
while(Local1)
{
Global_B=Parameter+5;
Parameter++;
Local1-=1;
}
Local1=Parameter+5;
Global_A|=Parameter;
Global_B=56;
while(1)
{
Global_B=Parameter+5;
Global_A+=2;
if(--Local1==0)
break;
}
Parameter&=Local2;
return Global_A;
}
void TestDo(void)
/******************************************************************************
Test of the do statement.
******************************************************************************/
{
char Local;
Local=TestWhile(Global_B)+5;
do
{
Global_B=Global_B+5;
Global_A-=3;
Local&=Global_B;
Global_A++;
Global_B|=Global_A;
Global_A=Global_B;
Global_B-=30;
Global_B--;
Global_B&=Local;
}
while(--Local);
}
char TestFor(void)
/******************************************************************************
Test of the for statement.
******************************************************************************/
{
char Local;
TestDo();
Local=Global_A+5;
for(;Local;Local--)
{
Global_B|=5;
Global_A+=2;
Local=Global_A-2;
Global_A++;
Global_B|=Global_A;
Local-=7;
Local&=Global_A;
Global_B--;
Global_A=10;
}
return Global_A;
}
void main(void)
/******************************************************************************
Main function.
******************************************************************************/
{
char Local;
Local=TestSwitch(Global_A);
TestIf(Global_B);
Global_B=TestWhile(Global_A);
TestDo();
Local=TestFor();
}
//*****************************************************************************
/* Resulting assembler file:
; CC5X Version 2.1I, Copyright (c) B. Knudsen Data
; C compiler for the PIC16CXX microcontroller family
; ************* 7. Jun 1999 10:26 **************
processor 16C67
Carry EQU 0
Zero_ EQU 2
RP0 EQU 5
RP1 EQU 6
Global_A EQU 0x2B
Global_B EQU 0x2C
Parameter EQU 0x26
Local1 EQU 0x27
Local2 EQU 0x28
Parameter_2 EQU 0x26
Local1_2 EQU 0x27
Local2_2 EQU 0x28
Local3 EQU 0x29
Parameter_3 EQU 0x23
Local1_3 EQU 0x24
Local2_3 EQU 0x25
Local EQU 0x22
Local_2 EQU 0x21
Local_3 EQU 0x20
GOTO main
; FILE C_BENCHM.c
;#include "16C67.h"
;
;// CC5X %y.c -O%x -CA%y.cod +%y.par > %y.err
;
;///* CC5X version without the pragma:*/
;//#ifdef __longIX
;// /* MPC setups. */
;// #pragma option v; /* Enable verbose symbol mode for PicMaster. */
;// #pragma option f0; /* Continuous listing without page brakes. */
;// #include "16c71.h"
;//#endif
;
;/******************************************************************************
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; <<<<< >>>>>
; <<<<< "Nonsense code" for test of C-compilers. >>>>>
; <<<<< >>>>>
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;
; c_benchm.c
; Rev. history : 950529 First version
; 950726 Version modified to be as close as possible to
; a real program. (About the same percentage of
; the different statements as in my software.)
; 990607 Added more local variables. Changed from
; 1 K device 16C71 to 8 K 16C67.
;
;******************************************************************************/
;
;char Global_A,Global_B;
;
;char TestSwitch(char Parameter)
;/******************************************************************************
; Test of the switch statement.
;******************************************************************************/
;{
TestSwitch
MOVWF Parameter
; char Local1,Local2;
;
MOVLW .65 ; Local2=Parameter+'A';
ADDWF Parameter,W
MOVWF Local2
MOVLW .65 ; Local1=Parameter+'A';
ADDWF Parameter,W
MOVWF Local1
MOVF Local2,W ; Local1+=Local2;
ADDWF Local1,1
;
MOVF Local1,W ; switch(Local1)
XORLW .65
BTFSC 0x03,Zero_
GOTO m001
XORLW .3
BTFSC 0x03,Zero_
GOTO m002
XORLW .1
BTFSC 0x03,Zero_
GOTO m003
XORLW .7
BTFSC 0x03,Zero_
GOTO m004
XORLW .1
BTFSC 0x03,Zero_
GOTO m005
XORLW .3
BTFSC 0x03,Zero_
GOTO m006
XORLW .1
BTFSC 0x03,Zero_
GOTO m007
GOTO m008
; {
m001 MOVLW .6 ; case 'A': Global_B+=6;break;
ADDWF Global_B,1
GOTO m008
m002 MOVLW .5 ; case 'B': Global_B=Parameter+5;Global_A=5;break;
ADDWF Parameter,W
MOVWF Global_B
MOVLW .5
MOVWF Global_A
GOTO m008
m003 MOVLW .2 ; case 'C': Global_B=Parameter+2;Global_A+=2;break;
ADDWF Parameter,W
MOVWF Global_B
MOVLW .2
ADDWF Global_A,1
GOTO m008
m004 MOVLW .10 ; case 'D': Global_B=Parameter-10;return '4';
SUBWF Parameter,W
MOVWF Global_B
RETLW .52
m005 MOVLW .5 ; case 'E': Global_B=Parameter+5;return Global_A;
ADDWF Parameter,W
MOVWF Global_B
MOVF Global_A,W
RETURN
m006 MOVLW .9 ; case 'F': Global_A-=9;break;
SUBWF Global_A,1
GOTO m008
m007 MOVLW .35 ; case 'G': Global_A=35;break;
MOVWF Global_A
; }
m008 MOVF Local1,W ; return Local1;
RETURN
;}
;
;void TestIf(char Parameter)
;/******************************************************************************
; Test of the if statement.
;******************************************************************************/
;{
TestIf
MOVWF Parameter_2
; char Local1,Local2,Local3,Local4;
;
MOVLW .5 ; Local1=Parameter+5;
ADDWF Parameter_2,W
MOVWF Local1_2
MOVF Global_A,W ; Local2=Global_A;
MOVWF Local2_2
ADDWF Local1_2,W ; Local3=Local1+Local2;
MOVWF Local3
;
MOVLW .5 ; if(Local1>=5 && Parameter==1)
SUBWF Local1_2,W
BTFSS 0x03,Carry
GOTO m009
DECFSZ Parameter_2,W
GOTO m009
; {
MOVLW .2 ; Global_A=Parameter+2;
ADDWF Parameter_2,W
MOVWF Global_A
MOVLW .12 ; Parameter=12;
MOVWF Parameter_2
; }
GOTO m010 ; else if(Local2<=5 && Parameter==2)
m009 MOVLW .6
SUBWF Local2_2,W
BTFSC 0x03,Carry
GOTO m010
MOVF Parameter_2,W
XORLW .2
BTFSS 0x03,Zero_
GOTO m010
; {
MOVLW .4 ; Parameter+=4;
ADDWF Parameter_2,1
MOVLW .2 ; Global_A=2;
MOVWF Global_A
; }
;
;
m010 MOVF Local3,W ; if(Local3==5 && Parameter==3)
XORLW .5
BTFSS 0x03,Zero_
GOTO m011
MOVF Parameter_2,W
XORLW .3
BTFSS 0x03,Zero_
GOTO m011
; {
DECF Global_A,1 ; Global_A-=1;
; }
GOTO m015 ; else if(Local1>5 || Parameter==4)
m011 MOVLW .6
SUBWF Local1_2,W
BTFSC 0x03,Carry
GOTO m012
MOVF Parameter_2,W
XORLW .4
BTFSS 0x03,Zero_
GOTO m013
; {
m012 MOVF Global_A,W ; Global_A&=Global_A;
ANDWF Global_A,1
INCF Parameter_2,1 ; Parameter++;
; }
GOTO m015 ; else if(Local2<5 || Parameter==5)
m013 MOVLW .5
SUBWF Local2_2,W
BTFSS 0x03,Carry
GOTO m014
MOVF Parameter_2,W
XORLW .5
BTFSC 0x03,Zero_
; {
m014 DECF Global_B,1 ; Global_B--;
; }
;
m015 MOVF Local3,W ; if(Local3==5)
XORLW .5
BTFSS 0x03,Zero_
GOTO m016
MOVLW .10 ; Global_B=Parameter+10;
ADDWF Parameter_2,W
MOVWF Global_B
GOTO m017 ; else
m016 MOVLW .20 ; Global_B=Parameter+20;
ADDWF Parameter_2,W
MOVWF Global_B
m017 RETURN ;}
;
;char TestWhile(char Parameter)
;/******************************************************************************
; Test of the while statement.
;******************************************************************************/
;{
TestWhile
MOVWF Parameter_3
; char Local1,Local2;
;
MOVF Global_B,W ; TestIf(Global_B);
CALL TestIf
;
MOVLW .5 ; Local1=Parameter+5;
ADDWF Parameter_3,W
MOVWF Local1_3
CALL TestSwitch ; Local2=TestSwitch(Local1);
MOVWF Local2_3
;
m018 MOVF Local1_3,1 ; while(Local1)
BTFSC 0x03,Zero_
GOTO m019
; {
MOVLW .5 ; Global_B=Parameter+5;
ADDWF Parameter_3,W
MOVWF Global_B
INCF Parameter_3,1 ; Parameter++;
DECF Local1_3,1 ; Local1-=1;
GOTO m018 ; }
;
m019 MOVLW .5 ; Local1=Parameter+5;
ADDWF Parameter_3,W
MOVWF Local1_3
MOVF Parameter_3,W ;Global_A|=Parameter;
IORWF Global_A,1
MOVLW .56 ; Global_B=56;
MOVWF Global_B
; while(1)
; {
m020 MOVLW .5 ; Global_B=Parameter+5;
ADDWF Parameter_3,W
MOVWF Global_B
MOVLW .2 ; Global_A+=2;
ADDWF Global_A,1
;
DECFSZ Local1_3,1 ; if(--Local1==0)
GOTO m020
; break;
; }
m021 MOVF Local2_3,W ; Parameter&=Local2;
ANDWF Parameter_3,1
MOVF Global_A,W ; return Global_A;
RETURN
;}
;
;void TestDo(void)
;/******************************************************************************
; Test of the do statement.
CF Global_B,1 ; Global_B--;
MOVLW .10 ; Global_A=10;
MOVWF Global_A
DECF Local_2,1 ; }
GOTO m023
;
m024 MOVF Global_A,W ; return Global_A;
RETURN
;}
;
;void main(void)
;/******************************************************************************
; Main function.
;******************************************************************************/
;{
main
; char Local;
;
BCF 0x03,RP0 ; Local=TestSwitch(Global_A);
BCF 0x03,RP1
MOVF Global_A,W
CALL TestSwitch
MOVWF Local_3
MOVF Global_B,W ; TestIf(Global_B);
CALL TestIf
MOVF Global_A,W ; Global_B=TestWhile(Global_A);
CALL TestWhile
MOVWF Global_B
CALL TestDo ; TestDo();
CALL TestFor ; Local=TestFor();
MOVWF Local_3
SLEEP ;}
GOTO main
END
·
1999\06\07@054753
by
Tjaart van der Walt
|
Anders Widgren wrote:
>
> >Anders made sweeping claims. I would also like to see an example of his resea
rch findings.
> >So, how about it, Anders? Let's have a look and see...
> >Friendly Regards /"\
> >Tjaart van der Walt X ASCII RIBBON CAMPAIGN
>
> The last time I did a more serious comparison between PIC C-compilers was in 1
995. The problem was to come up with code that would work under several of these
rather simple C-compilers. It would be much more interesting to use code from a
n actual "typical" project. I might do something like that during the summer. Th
e code below compiled by CC5X for a 16C67 device resulted in 238 instructions an
d 13 RAM bytes. How much code does your compiler generate for the same code? Of
course, in a real project I would probably use a look-up table instead of a case
structure. (CC5X has a skip() instructions that automatically generates checked
look-up tables.)
<lots of code snipped>
I am hoping someone else will run this through MPC.
I haven't the time. It will be interesting....
--
Friendly Regards /"\
\ /
Tjaart van der Walt X ASCII RIBBON CAMPAIGN
@spam@tjaartKILLspam
wasp.co.za / \ AGAINST HTML MAIL
|--------------------------------------------------|
| Cellpoint Systems SA http://www.cellpt.com |
|--------------------------------------------------|
| http://www.wasp.co.za/~tjaart/index.html |
| WGS84 : -26.0124 +28.1129 |
| Voice : +27 (0)11 2545100 |
|--------------------------------------------------|
1999\06\07@062530
by
Michael Rigby-Jones
Using the HiTech compiler this gave a total of 263 words, of which 19 are
used for ram initialisation etc. giving 244 words of ROM and 12 bytes of
RAM. Six words more ROM and one word less RAM, pretty close I think.
The ASM list file is a bit messy (and long). Do any of you hitech users
know if it's possible to just get an assembly listing without all the C code
in it? I'll post it if you want though.
BTW there's an unused variable Local4 in the TestIf function.
Regards
Mike Rigby-Jones
> {Original Message removed}
1999\06\07@075552
by
Anders Widgren
part 0 2351 bytes
The main reason why MPC produced so much extra code was that it didn't optimize code/bank bits at all. (The bits were always set/cleared before any function/variable was used.) Also, simple things like if(x>=5) resulted in two tests instead of comparing "if greater than 4"!!! It didn't reuse variable space either. In my application it meant that code generated by MPC needed three times as much RAM-space! Have these problems been solved in the latest version of MPC?
-AW
{Original Message removed}
1999\06\07@085421
by
Anders Widgren
part 0 2573 bytes
; CC5X Version 3.0, Copyright (c) B. Knudsen Data
; C compiler for the PICmicro family
; ************ 7. Jun 1999 14:24 *************
Carry EQU 0
Zero_ EQU 2
RP0 EQU 5
RP1 EQU 6
Global_A EQU 0x2A
Global_B EQU 0x2B
Parameter EQU 0x26
Local1 EQU 0x27
Local2 EQU 0x28
Parameter_2 EQU 0x26
Local1_2 EQU 0x27
Local2_2 EQU 0x28
Local3 EQU 0x29
Parameter_3 EQU 0x23
Local1_3 EQU 0x24
Local2_3 EQU 0x25
Local EQU 0x22
Local_2 EQU 0x21
Local_3 EQU 0x20
-AW
{Original Message removed}
1999\06\07@091511
by
Clyde Smith-Stubbs
1999\06\07@091733
by
Michael Rigby-Jones
I know that the initialisation routine in HiTech can be customised, and I
think (help me out here guys) even removed so the real figure is about 2.5%.
I've never actually bothered doing this and the manual isn't very handy so I
can't be more specific. From recent discussions on here with Clyde I think
that there are some further optimisations in progress as well. Watch out,
they're close behind!
Regards
Mike Rigby-Jones
> {Original Message removed}
1999\06\07@104943
by
Andy Kunz
>I know that the initialisation routine in HiTech can be customised, and I
>think (help me out here guys) even removed so the real figure is about 2.5%.
Yes, it can be removed. Did that once.
Andy
==================================================================
INTRODUCTORY PRICING ENDS JULY 1, 1999
==================================================================
Andy Kunz Life is what we do to prepare for Eternity
------------------------------------------------------------------
spamBeGoneandyspamBeGone
rc-hydros.com http://www.rc-hydros.com - Race Boats
TakeThisOuTandyEraseME
spam_OUTmontanadesign.com http://www.montanadesign.com - Electronics
==================================================================
1999\06\07@104955
by
Andy Kunz
|
>the HiTech is now optimizing the code! I bought HiTech when it first came
And has been for a LOOOOONG time.
>to make anything out of the generated ASM-file which was very messy.
Uh, what's the point here? I use the generated files on occasion, and
don't consider them messy. They are typical of "real" assemblers (you
know, relocatable code, etc.). They are very easy to understand if you
consider that they are compiler output and not intended for human
consumption. Try reading and comprehending the assembly output of M$
Visual C++ sometime!!!
I find it disheartening that CC5X doesn't zero all variables at
initialization, as per the C spec. CC5X has taken shortcuts when it didn't
suit their fancy. I think Clyde did a great service by giving an honest
review of the product.
Walter, what do you think of CC5X? Of Clyde's review?
Andy
==================================================================
INTRODUCTORY PRICING ENDS JULY 1, 1999
==================================================================
Andy Kunz Life is what we do to prepare for Eternity
------------------------------------------------------------------
RemoveMEandy
TakeThisOuTrc-hydros.com http://www.rc-hydros.com - Race Boats
andyEraseME
.....montanadesign.com http://www.montanadesign.com - Electronics
==================================================================
1999\06\07@115834
by
Sean Breheny
At 09:45 AM 6/7/99 -0400, you wrote:
>I find it disheartening that CC5X doesn't zero all variables at
>initialization, as per the C spec. CC5X has taken shortcuts when it didn't
>suit their fancy. I think Clyde did a great service by giving an honest
>review of the product.
Andy, I never heard of any part of the C spec that guarantees zeroed
variables at startup! I have used Borland Turbo C++ for several years for
programming PCs and I never remember any such guarantee. IN fact, I seem to
remember just the opposite being said (i.e.,you must initialize the vars
yourself,as opposed to other higher-level languages such as BASIC).
Sean
{Quote hidden}
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
RemoveMEshb7spam_OUT
KILLspamcornell.edu ICQ #: 3329174
________________________________________________________
NetZero - We believe in a FREE Internet. Shouldn't you?
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html
1999\06\07@134511
by
James Grosbach
|
>Andy, I never heard of any part of the C spec that guarantees zeroed
>variables at startup! I have used Borland Turbo C++ for several years for
>programming PCs and I never remember any such guarantee. IN fact, I seem to
>remember just the opposite being said (i.e.,you must initialize the vars
>yourself,as opposed to other higher-level languages such as BASIC).
For automatic variables, no, but static duration variables, yes.
ANS X3.159-1989 3.5.7 Initialization
"If an object that has automatic storage duration is not initialized
explicitly, its value is indeterminate. If an object that has static
storage duration is not initialized explicitly, it is initialized
implicitly as if every member that has arithmetic type were assigned 0 and
every member that has pointer type were assigned a null pointer constant."
It is not unreasonable, IMO, for compilers for small processors to, at
least optionally, waive the implicit initialization of static duration
objects, as it's good style to explicitly initialize any variable upon
whose startup-value the program will depend and initializing a bunch of
locations to zero when it's not necessary can chew up a lot of cycles at
startup that could be put to better use.
Jim
James Grosbach
Development Systems
Microchip Technology
RemoveMEjames.grosbachTakeThisOuT
spammicrochip.com
1999\06\07@140657
by
David Knaack
|
From: James Grosbach <EraseMEjames.grosbachspam
spamBeGoneMICROCHIP.COM>
>>Andy, I never heard of any part of the C spec that guarantees zeroed
>>variables at startup! I have used Borland Turbo C++ for several years for
>>programming PCs and I never remember any such guarantee. IN fact, I seem
to
>>remember just the opposite being said (i.e.,you must initialize the vars
>>yourself,as opposed to other higher-level languages such as BASIC).
>
>For automatic variables, no, but static duration variables, yes.
>
>ANS X3.159-1989 3.5.7 Initialization
> "If an object that has automatic storage duration is not
initialized
>explicitly, its value is indeterminate. If an object that has static
>storage duration is not initialized explicitly, it is initialized
>implicitly as if every member that has arithmetic type were assigned 0 and
>every member that has pointer type were assigned a null pointer constant."
I don't know the context here (I haven't looked up the standard), but
this appears to apply to object oriented programming ('object' and
'member' are OOP related ).
Borland Delphi which is not C obviously, but its objects follow many of
the same rules follows this standard. 'Global' variables (those that
are not members of an object) are not initialized, variables that are
members of an object are initialized to 0 (nil, false, etc). I'm not
sure what the definition of "automatic storage duration" and
"static storage duration" are in this context though.
So:
Does this standard refer to initialization for objects in OOP programming?
If so:
Do these microcontroller C languages provide OOP techniques?
(inheritance, polymorphism, etc)?
If not I'd submit that this standard does not apply.
Also, as far as I am aware, C compilers don't have to meet any
standards to be called 'C'. They have to meet the ANSI standard
to be ANSI compliant of course. So the maker of the compiler
could initialize them or not, as it suited their needs.
DK
1999\06\07@144514
by
James Grosbach
|
>>ANS X3.159-1989 3.5.7 Initialization
[...]
>I don't know the context here (I haven't looked up the standard), but
>this appears to apply to object oriented programming ('object' and
>'member' are OOP related ).
[...]
>Does this standard refer to initialization for objects in OOP programming?
The standard for C++ has similar language, but this particular quote refers
to ANSI/ISO C only. It is the C language specification. Specifically:
ANSI X3-159-1989: "American National Standard for Information Systems--
Programming Language-- C"
>Also, as far as I am aware, C compilers don't have to meet any
>standards to be called 'C'. They have to meet the ANSI standard
>to be ANSI compliant of course. So the maker of the compiler
>could initialize them or not, as it suited their needs.
True. Though most compilers try to be as close as reasonable to the ANSI
standard even when they don't fully comply so as to enhance code
portability. Things get tricky regarding different vendors' definitions of
"reasonable."
As another example, many C compilers for 8-bit architectures, at least
optionally, suppress the integer promotions for integer arithmetic. That
allows much more reasonably sized code at the expense of some subtle
differences in expression results when compared to a strictly conforming
implementation.
Jim
James Grosbach
Development Systems
Microchip Technology
RemoveMEjames.grosbachKILLspam
microchip.com
1999\06\07@155424
by
Andy Kunz
>Andy, I never heard of any part of the C spec that guarantees zeroed
>variables at startup! I have used Borland Turbo C++ for several years for
I have, but not having a book handy...
What do CLyde and Walter have to say?
Andy
==================================================================
INTRODUCTORY PRICING ENDS JULY 1, 1999
==================================================================
Andy Kunz Life is what we do to prepare for Eternity
------------------------------------------------------------------
andySTOPspam
spam_OUTrc-hydros.com http://www.rc-hydros.com - Race Boats
spamBeGoneandySTOPspam
EraseMEmontanadesign.com http://www.montanadesign.com - Electronics
==================================================================
1999\06\07@170526
by
Walter Banks
Andy
>
> Walter, what do you think of CC5X?
It is enhanced structured assembler.
> Of Clyde's review?
>
There are things Clyde and I can agree on. He
has gone to a lot more effort than I have to look
at CC5X. I found serious scoping problems and
broken conditional branches.
Walter Banks
1999\06\07@181116
by
Sean Breheny
Thanks for the info.
I didn't know that we were making a distinction between different kinds of
variables in the earlier discussion, but I can see how it is important.
Probably my Turbo C++ isn't completely ANSI compatible because I seem to
remember defining global arrays and upon inspecting them,finding only the
portion that I actually set being initialized,the rest containing "random"
data.
Actually, I just went and tried it,and lo and behold,it IS initializing
global arrays to zero. I stand corrected, must be my memory playing tricks
on me ;-)
Oh, BTW, another C question for the experts: Is this legal ANSI C?
#include <stdio.h>
void main ( void )
{
printf ( "Hello!\n" );
{
int j;
printf ( "Hi!\n" );
};
};
I always thought that extra sets of braces (without starting a new function
or a for, while, etc.) were illegal in ANSI C AND that declaring variables
after the start of code like this (unless beginning a new function) was
illegal. I thought those things were only allowed in C++. HOWEVER, Turbo
C++ compiles it fine EVEN with the C++ functionality turned off (should
make it a regular C compiler).
Can someone please set me straight?
Thanks,
Sean
At 01:45 PM 6/7/99 -0400, you wrote:
{Quote hidden}>For automatic variables, no, but static duration variables, yes.
>
>ANS X3.159-1989 3.5.7 Initialization
> "If an object that has automatic storage duration is not initialized
>explicitly, its value is indeterminate. If an object that has static
>storage duration is not initialized explicitly, it is initialized
>implicitly as if every member that has arithmetic type were assigned 0 and
>every member that has pointer type were assigned a null pointer constant."
>
>It is not unreasonable, IMO, for compilers for small processors to, at
>least optionally, waive the implicit initialization of static duration
>objects, as it's good style to explicitly initialize any variable upon
>whose startup-value the program will depend and initializing a bunch of
>locations to zero when it's not necessary can chew up a lot of cycles at
>startup that could be put to better use.
>
> Jim
>
>James Grosbach
>Development Systems
>Microchip Technology
>
KILLspamjames.grosbachspamBeGone
microchip.com
>
|
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
EraseMEshb7
EraseMEcornell.edu ICQ #: 3329174
________________________________________________________
NetZero - We believe in a FREE Internet. Shouldn't you?
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html
1999\06\07@183636
by
Matt Bonner
Sean Breheny wrote:
>
> #include <stdio.h>
>
> void main ( void )
Just to be picky: "main" actually returns an int:
int main (void)
Although I've never seen a compiler give even a warning.
> {
> printf ( "Hello!\n" );
> {
> int j;
> printf ( "Hi!\n" );
> };
> };
>
My old MS C compiler for DOS doesn't choke on extra braces either,
although I didn't turn off the C++ compatibility (I like // for
single-line comments).
Sometimes extra braces can improve coding structure. *Sometimes*. The
important thing is to make sure the code is readable 6 months from now.
--Matt
1999\06\07@185925
by
Eric Oliver
Sean,
I believe global vars are zeroed.
On Monday, June 07, 1999 10:56 AM, Sean Breheny [SMTP:@spam@shb7@spam@
spam_OUTCORNELL.EDU] wrote:
{Quote hidden}> At 09:45 AM 6/7/99 -0400, you wrote:
> >I find it disheartening that CC5X doesn't zero all variables at
> >initialization, as per the C spec. CC5X has taken shortcuts when it didn't
> >suit their fancy. I think Clyde did a great service by giving an honest
> >review of the product.
>
> Andy, I never heard of any part of the C spec that guarantees zeroed
> variables at startup! I have used Borland Turbo C++ for several years for
> programming PCs and I never remember any such guarantee. IN fact, I seem to
> remember just the opposite being said (i.e.,you must initialize the vars
> yourself,as opposed to other higher-level languages such as BASIC).
>
> Sean
>
>
1999\06\07@211006
by
Clyde Smith-Stubbs
On Mon, Jun 07, 1999 at 06:10:02PM -0400, Sean Breheny wrote:
> Oh, BTW, another C question for the experts: Is this legal ANSI C?
Yes, functions in C can have inner blocks, which represent a new scope,
and can have their own local variables.
Regards, Clyde
--
Clyde Smith-Stubbs | HI-TECH Software
Email: spamBeGoneclyde
KILLspamhtsoft.com | Phone Fax
WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885
PGP: finger .....clydespam_OUT
htsoft.com | AUS: +61 7 3355 8333 +61 7 3355 8334
---------------------------------------------------------------------------
HI-TECH C: compiling the real world.
1999\06\07@220329
by
Sean Breheny
Thanks to those who responded. As for the main int vs. void, I thought the
programmer had the option of telling the compiler whether or not main will
return an int or return nothing just by changing the declaration.
As for the inner blocks, I am genuinely surprised because this:
for (int x = 2; x < 10 ; x++);
is not allowed by my compiler in ANSI C mode but IS allowed in C++ mode.
If variable definitions ARE allowed in the middle of code, then why not
allow them in the middle of the init code for a FOR loop?
So, when I do a { in C, it will start a new stack frame to support my new
local vars?
Thanks,
Sean
At 11:07 AM 6/8/99 +1000, you wrote:
{Quote hidden}>On Mon, Jun 07, 1999 at 06:10:02PM -0400, Sean Breheny wrote:
>
>> Oh, BTW, another C question for the experts: Is this legal ANSI C?
>
>Yes, functions in C can have inner blocks, which represent a new scope,
>and can have their own local variables.
>
>
>Regards, Clyde
>
>--
>Clyde Smith-Stubbs | HI-TECH Software
>Email:
TakeThisOuTclyde.....
TakeThisOuThtsoft.com | Phone Fax
>WWW:
http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885
>PGP: finger
TakeThisOuTclydeKILLspam
spamhtsoft.com | AUS: +61 7 3355 8333 +61 7 3355 8334
>---------------------------------------------------------------------------
>HI-TECH C: compiling the real world.
>
|
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
.....shb7
RemoveMEcornell.edu ICQ #: 3329174
________________________________________________________
NetZero - We believe in a FREE Internet. Shouldn't you?
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html
1999\06\07@224624
by
Eric Oliver
|
Sean,
Sorry, I can't really comment on whether the extra braces are illegal in
ANSI C. I can say that I too started with Turbo C and move to Borland C++
3.xx - 5.xx. As far I remember, it has always been legal to use braces to
define a new scope. Variables declared within the braces are local to that
scope only. Always used a mix of C/C++ so maybe that's why I've never
noticed otherwise.
I compiled the following in a file called test.c under Borland C++ 5.02.
With i = i + j commented, it compiles without error. Uncommenting the line
produces an error that j is undefined. Note that compiling a file with the
.c extension should compile it as C source not C++. I compiled with the
compiler set to both ANSI language compliance and then Kernighan and
Ritchie without error.
int test()
{
int i = 5;
{
int j = 1;
j = j+1;
}
//i = i + j;
}
I know that this doesn't explicitely answer your question, but I suspect
that using braces to create a local scope is legal ANSI C.
Eric
On Monday, June 07, 1999 5:10 PM, Sean Breheny [SMTP:RemoveMEshb7
spamBeGoneCORNELL.EDU]
wrote:
> Thanks for the info.
>
> I didn't know that we were making a distinction between different kinds
of
> variables in the earlier discussion, but I can see how it is important.
> Probably my Turbo C++ isn't completely ANSI compatible because I seem to
> remember defining global arrays and upon inspecting them,finding only the
> portion that I actually set being initialized,the rest containing
"random"
> data.
>
> Actually, I just went and tried it,and lo and behold,it IS initializing
> global arrays to zero. I stand corrected, must be my memory playing
tricks
{Quote hidden}> on me ;-)
>
> Oh, BTW, another C question for the experts: Is this legal ANSI C?
>
> #include <stdio.h>
>
> void main ( void )
> {
> printf ( "Hello!\n" );
> {
> int j;
> printf ( "Hi!\n" );
> };
> };
>
> I always thought that extra sets of braces (without starting a new
function
> or a for, while, etc.) were illegal in ANSI C AND that declaring
variables
{Quote hidden}> after the start of code like this (unless beginning a new function) was
> illegal. I thought those things were only allowed in C++. HOWEVER, Turbo
> C++ compiles it fine EVEN with the C++ functionality turned off (should
> make it a regular C compiler).
>
> Can someone please set me straight?
>
> Thanks,
>
> Sean
>
>
> At 01:45 PM 6/7/99 -0400, you wrote:
> >For automatic variables, no, but static duration variables, yes.
> >
> >ANS X3.159-1989 3.5.7 Initialization
> > "If an object that has automatic storage duration is not
initialized
> >explicitly, its value is indeterminate. If an object that has static
> >storage duration is not initialized explicitly, it is initialized
> >implicitly as if every member that has arithmetic type were assigned 0
and
> >every member that has pointer type were assigned a null pointer
constant."
{Quote hidden}> >
> >It is not unreasonable, IMO, for compilers for small processors to, at
> >least optionally, waive the implicit initialization of static duration
> >objects, as it's good style to explicitly initialize any variable upon
> >whose startup-value the program will depend and initializing a bunch of
> >locations to zero when it's not necessary can chew up a lot of cycles at
> >startup that could be put to better use.
> >
> > Jim
> >
> >James Grosbach
> >Development Systems
> >Microchip Technology
> >
spamBeGonejames.grosbach@spam@
spam_OUTmicrochip.com
> >
> |
> | Sean Breheny
> | Amateur Radio Callsign: KA3YXM
> | Electrical Engineering Student
> \--------------=----------------
> Save lives, please look at
http://www.all.org
> Personal page:
http://www.people.cornell.edu/pages/shb7
>
>
>
TakeThisOuTshb7spam
cornell.edu ICQ #: 3329174
> ________________________________________________________
> NetZero - We believe in a FREE Internet. Shouldn't you?
> Get your FREE Internet Access and Email at
>
http://www.netzero.net/download/index.html
1999\06\07@230809
by
Eric Oliver
>
> for (int x = 2; x < 10 ; x++);
>
Yes, I believe this was added in ANSI C++.
Eric
1999\06\07@231206
by
Sean Breheny
Thanks Eric! It is really just a curiousity I have. I always though it was
illegal,but a couple of weeks ago, a friend of mine showed me a piece of
code he wrote which had them in it. At the time, I didn't even know the
extra braces were legal in C++, but since he was using a CPP extension, I
assumed that it was legal (but only for C++). I tried it on my compiler
with a .C extension (and the compiler set to use only regular ANSI C when a
.C extension is used) and it worked, too. however, Turbo C++ (which I used,
don't remember the version number), also allows // comments in ANSI C mode,
so it didn't convince me of anything. That's why I thought I would take
this opportunity to ask the list! <G>
Sean
At 09:10 PM 6/7/99 -0500, you wrote:
{Quote hidden}>Sean,
>
>Sorry, I can't really comment on whether the extra braces are illegal in
>ANSI C. I can say that I too started with Turbo C and move to Borland C++
>3.xx - 5.xx. As far I remember, it has always been legal to use braces to
>define a new scope. Variables declared within the braces are local to that
>scope only. Always used a mix of C/C++ so maybe that's why I've never
>noticed otherwise.
>
>I compiled the following in a file called test.c under Borland C++ 5.02.
>With i = i + j commented, it compiles without error. Uncommenting the line
>produces an error that j is undefined. Note that compiling a file with the
>.c extension should compile it as C source not C++. I compiled with the
>compiler set to both ANSI language compliance and then Kernighan and
>Ritchie without error.
>
>int test()
> {
>
> int i = 5;
>
> {
> int j = 1;
> j = j+1;
> }
>
> //i = i + j;
>
> }
>
>I know that this doesn't explicitely answer your question, but I suspect
>that using braces to create a local scope is legal ANSI C.
>
>Eric
>
>On Monday, June 07, 1999 5:10 PM, Sean Breheny [SMTP:
shb7EraseME
CORNELL.EDU]
>wrote:
>> Thanks for the info.
>>
>> I didn't know that we were making a distinction between different kinds
>of
>> variables in the earlier discussion, but I can see how it is important.
>> Probably my Turbo C++ isn't completely ANSI compatible because I seem to
>> remember defining global arrays and upon inspecting them,finding only the
>> portion that I actually set being initialized,the rest containing
>"random"
>> data.
>>
>> Actually, I just went and tried it,and lo and behold,it IS initializing
>> global arrays to zero. I stand corrected, must be my memory playing
>tricks
>> on me ;-)
>>
>> Oh, BTW, another C question for the experts: Is this legal ANSI C?
>>
>> #include <stdio.h>
>>
>> void main ( void )
>> {
>> printf ( "Hello!\n" );
>> {
>> int j;
>> printf ( "Hi!\n" );
>> };
>> };
>>
>> I always thought that extra sets of braces (without starting a new
>function
>> or a for, while, etc.) were illegal in ANSI C AND that declaring
>variables
>> after the start of code like this (unless beginning a new function) was
>> illegal. I thought those things were only allowed in C++. HOWEVER, Turbo
>> C++ compiles it fine EVEN with the C++ functionality turned off (should
>> make it a regular C compiler).
>>
>> Can someone please set me straight?
>>
>> Thanks,
>>
>> Sean
>>
>>
>> At 01:45 PM 6/7/99 -0400, you wrote:
>> >For automatic variables, no, but static duration variables, yes.
>> >
>> >ANS X3.159-1989 3.5.7 Initialization
>> > "If an object that has automatic storage duration is not
>initialized
>> >explicitly, its value is indeterminate. If an object that has static
>> >storage duration is not initialized explicitly, it is initialized
>> >implicitly as if every member that has arithmetic type were assigned 0
>and
>> >every member that has pointer type were assigned a null pointer
>constant."
>> >
>> >It is not unreasonable, IMO, for compilers for small processors to, at
>> >least optionally, waive the implicit initialization of static duration
>> >objects, as it's good style to explicitly initialize any variable upon
>> >whose startup-value the program will depend and initializing a bunch of
>> >locations to zero when it's not necessary can chew up a lot of cycles at
>> >startup that could be put to better use.
>> >
>> > Jim
>> >
>> >James Grosbach
>> >Development Systems
>> >Microchip Technology
>> >
RemoveMEjames.grosbachEraseME
spam_OUTmicrochip.com
>> >
>> |
>> | Sean Breheny
>> | Amateur Radio Callsign: KA3YXM
>> | Electrical Engineering Student
>> \--------------=----------------
>> Save lives, please look at
http://www.all.org
>> Personal page:
http://www.people.cornell.edu/pages/shb7
>>
>>
>>
@spam@shb7RemoveME
EraseMEcornell.edu ICQ #: 3329174
>> ________________________________________________________
>> NetZero - We believe in a FREE Internet. Shouldn't you?
>> Get your FREE Internet Access and Email at
>>
http://www.netzero.net/download/index.html
>
|
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
EraseMEshb7
@spam@cornell.edu ICQ #: 3329174
________________________________________________________
NetZero - We believe in a FREE Internet. Shouldn't you?
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html
1999\06\07@231611
by
Clyde Smith-Stubbs
|
On Mon, Jun 07, 1999 at 10:00:17PM -0400, Sean Breheny wrote:
>
> for (int x = 2; x < 10 ; x++);
>
> is not allowed by my compiler in ANSI C mode but IS allowed in C++ mode.
> If variable definitions ARE allowed in the middle of code, then why not
There's a subtle distinction here; C++ allows variable declarations anywhere
in a block; C allows them only at the beginning of a block. Thus C doesn't
actually allow declarations in the middle of code at all.
The reason for C not allowing them anywhere is mainly because of some
implementation difficulties (the syntax for C++ has some potential ambiguities
that are tricky to resolve sensibly), and because
the arguments for allowing them anywhere aren't particularly strong.
I'm personally very happy to put all declarations in one place in a block; it
makes for a tidier layout.
> So, when I do a { in C, it will start a new stack frame to support my new
> local vars?
No, the same stack frame is used, but a good C compiler will reuse stack frame
space for disjoint blocks, e.g.
func()
{
int a;
{
int b;
}
{
int c;
}
}
Will result in a stack frame that is the size of two ints; b and c will share
space, since they don't exist at the same time. The total stack frame size is
the maximum size required.
It would be possible to increase and decrease the stack frame size each time
a block was entered and exited, but I'm not aware of any implementations that
do that - instead the entire stack frame is allocated on function entry.
Of course on a PIC, the stack frame is allocated at compile time, but
the above discussion still applies.
Regards, Clyde
--
Clyde Smith-Stubbs | HI-TECH Software
Email: @spam@clydespam_OUT
.....htsoft.com | Phone Fax
WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885
PGP: finger spamBeGoneclydeEraseME
htsoft.com | AUS: +61 7 3355 8333 +61 7 3355 8334
---------------------------------------------------------------------------
HI-TECH C: compiling the real world.
1999\06\08@011140
by
William Chops Westfield
I think the last time I tried to create a local scope with just a set
of braces, the compiler I was using didn't let me. However, something like:
main ()
{
do {
int i,j,k;
/*
* code involving i,j,k...
*/
} until (0);
}
is clearly legal and has about the same effect.
BillW
1999\06\08@031013
by
w. v. ooijen / f. hanneman
|
At last a benchmark I can pit my JAL compiler against!
I did a quick translation to JAL. Problems I encountered:
- no switch statement, nor table-lookup (hence a chain of elsif's)
- no short-circuit && and ||
- no do ... while(...) , used "for N" instead
- no for(..;..;..), used "while" instead
JAL supports only 16f84 and SX, so I can only show those results:
JAL 16f84 code: 304 file: 16 stack: 4
JAL SX code: 561 file: 33 stack: 4
compared to:
C5XX 16c67 code: 238 file: 13 stack: 4 (I assume)
I don't have the manuals at hand, but I assume the 16c67 is a midrange,
so it is compareable to a 16f84? Maybe someone can give the figures
for 16f84 and SX?
Assuming 16c67 and 16f84 figures can be compared I still have
some work to do! I think I'll start comparing the generated code....
Still: not that bad for a $0 product (for the 16f84. the SX code
generation needs a lot of work). Any of the other free compilers
that takes up the challenge?
But one think I dearly missed in the benchmark is bit manipulation:
how do you set, reset, test etc. the IO pins? I hope not via bit masks?
regards
Wouter.
1999\06\08@083310
by
Walter Banks
>
> >Andy, I never heard of any part of the C spec that guarantees zeroed
> >variables at startup! I have used Borland Turbo C++ for several years
for
>
> I have, but not having a book handy...
>
> What do CLyde and Walter have to say?
K & R used a PDP-11 and the loader on a PDP-11
cleared core first then loaded binary files. I believe that
it is in the ISO spec to clear global variables. MPC will
clear RAM if any variables are initialized and will leave
RAM alone if no variables are initialized. This allows the
RESET vector to be used as a high priority interrupt
as a debug aid in production testing and for those
applications that absolutely needs a
Non Maskable Interrupt.
Walter Banks
1999\06\08@105746
by
James Grosbach
>Oh, BTW, another C question for the experts: Is this legal ANSI C?
>
>#include <stdio.h>
>
>void main ( void )
>{
> printf ( "Hello!\n" );
> {
> int j;
> printf ( "Hi!\n" );
> };
>};
The compound statement there is perfectly legal. A compound statement can
be used anywhere any other statement is legal. The ';' after the closing
brace isn't necessary, though. And the ';' after the function body's
closing brace is a syntax error, albeit one that most compilers will ignore.
You'll sometimes see macros use this to get some temp storage.
e.g.,
#define MyMacro(a) {int __x;/*do stuff*/}
Jim
1999\06\08@151921
by
w. v. ooijen / f. hanneman
I studied the differences between the code generated for
Anders' 'benchmark' by C5XX (Anders' c code) and by my
JAL compiler (from my translation to jal). A few relatively
simple changes closed the larger part of the gap:
C5XX: 238 instructions, JAL (0.4-18): 260 instructions
(was 305 for 0.4-17, so 17% better now). I think
closing the remaining gap will be much harder.
Now the funny thing is that the improvements in the
JAL compiler have far les impact on two programs I
received from JAL users (0.3% and 2.3%). I think
the lesson here is that personal coding style
can have a large impact....
But more of these 'challenges' are very welcome,
especially for more-or-less real applications!
Wouter.
1999\06\09@014916
by
Clyde Smith-Stubbs
On Tue, Jun 08, 1999 at 10:57:46AM -0400, James Grosbach wrote:
> brace isn't necessary, though. And the ';' after the function body's
> closing brace is a syntax error, albeit one that most compilers will ignore.
No, it's not a syntax error, it's a legal empty declaration.
Clyde
--
Clyde Smith-Stubbs | HI-TECH Software
Email: clydespamBeGone
htsoft.com | Phone Fax
WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885
PGP: finger RemoveMEclyde@spam@
spamBeGonehtsoft.com | AUS: +61 7 3355 8333 +61 7 3355 8334
---------------------------------------------------------------------------
HI-TECH C: compiling the real world.
1999\06\09@032222
by
Michael Rigby-Jones
|
> I studied the differences between the code generated for
> Anders' 'benchmark' by C5XX (Anders' c code) and by my
> JAL compiler (from my translation to jal). A few relatively
> simple changes closed the larger part of the gap:
> C5XX: 238 instructions, JAL (0.4-18): 260 instructions
> (was 305 for 0.4-17, so 17% better now). I think
> closing the remaining gap will be much harder.
>
> Now the funny thing is that the improvements in the
> JAL compiler have far les impact on two programs I
> received from JAL users (0.3% and 2.3%). I think
> the lesson here is that personal coding style
> can have a large impact....
>
> But more of these 'challenges' are very welcome,
> especially for more-or-less real applications!
>
> Wouter.
>
Isn't your Jal language for the 16X84 only? To be fair I recompiled the
code with HiTech with the target set to a 16F84. The results are
interesting:
240 words Program(not including initialisation) 17 Words for initialisation.
12 Words RAM.
This is using the very latest version 7.84 released yesterday. Compiling
for the original 16C67 target gave a program size of 243 words, saving 1
word for program memory over the previous version.
Regards
Mike Rigby-Jones
1999\06\09@110800
by
James Grosbach
At 10:48 PM 6/8/99 -0700, you wrote:
>On Tue, Jun 08, 1999 at 10:57:46AM -0400, James Grosbach wrote:
>> brace isn't necessary, though. And the ';' after the function body's
>> closing brace is a syntax error, albeit one that most compilers will
ignore.
>
>No, it's not a syntax error, it's a legal empty declaration.
Empty declarations are not legal according to the ANSI specification.
Section 3.5 says "A declaration shall declare at least a declarator, a tag,
or the members of an enumeration." An empty declaration does none of these.
The upcoming C9X (looking more like it'll be C0X...) standard maintains
this language. It's a common extension, however, and probably a good one. I
think that it's a fairly silly restriction on the part of the ANSI/ISO
committees, really.
Jim
James Grosbach
Development Systems
Microchip Technology
.....james.grosbach@spam@
EraseMEmicrochip.com
1999\06\10@012926
by
w. v. ooijen / f. hanneman
> Isn't your Jal language for the 16X84 only? To be fair I recompiled the
> code with HiTech with the target set to a 16F84:
> 240 words Program(not including initialisation) 17 Words for
initialisation.
> 12 Words RAM.
Thanks for the figures! Based on this simplistic 'benchmark' and for the
16x84
target JAL does not compare too bad against the professional compilers.
Of course that is also all one can say from this example!
Anyone got the code size figure for the SX?
I think I'll hack a something-like-C front end to JAL that can accept at
least
Anders' 'benchmark'. For such a small C subset that is little work.
regards,
Wouter.
More... (looser matching)
- Last day of these posts
- In 1999
, 2000 only
- Today
- New search...