[EMAIL PROTECTED] wrote: > Hi listers, > > I have problems polling volatile variable from "extern" main(). Here are > details: > > Compiler: > ======= > I use this distribution: (output from "sdcc -v") > SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 > 2.5.6 #4264 (Jul 6 2006) > > OS: > === > Win2000 > > Chip: > ==== > AT89S52 > > Simulator: > ======= > JSIM 4.05 (Freeware from Jens Altmann) > > Project files: (details are attached) > ========= > sys.h > sys.c > project1.c > project2.c > > Commands: ( -L and -I paths are stripped) > ========= > x:/>sdcc -c sys.c > x:/>sdcc project.c sys.rel > x:/>packihx project.ihx > project.hex > > Problems: > ======= > When I compiled the project1.c in modular way, with: ( -L and -I paths > are stripped) > x:/>sdcc -c sys.c > x:/>sdcc project1.c sys.rel > polling volatile variable TIMEOUT from main() is failed. > > When I merged "sys.h", "sys.c" in single file "project2.c" and do single > file compilation, > x:\sdcc project2.c > polling volatile variable TIMEOUT from main() is successfull. > > Please anyone help me. > I prefer modular compilation. > I usually break source files in modules and build them with Borland's make. > > Regards, > Fahmy > > Look at the assembler listing file generated at the output and you will see. There is no interrupt code generated (or there was not in my simple test case I derived from this code ... )
The key here seems to be that SDCC looks like it either does 'compile' OR 'link' in one command line invocation. It also cannot compile more than one source file on a single command line. So that sdcc project1.c sys.rel Has actually the same effect as sdcc project1.c And the sys.rel bit is ignored :-) The problem is worsened by the fact that the code defines the volatile variable TIMEOUT twice, once in sys.c and once in project1.c according to the code given. The failure to take any notice of the users request to link sys.rel then covers up this problem. Modular compilation would be more like sdcc -c sys.c sdcc -c project1.c sdcc -o project.ihx project1.rel sys.rel Which is what a make tool would execute. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user