From: SourceForge.net <no...@so...> - 2006-09-30 08:56:02
|
Bugs item #1358533, was opened at 2005-11-17 00:02 Message generated for change (Comment added) made by vvillatora You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1358533&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: z80 port Group: None Status: Open Resolution: None Priority: 5 Submitted By: Steven J Tucker (atarimax) Assigned to: Nobody/Anonymous (nobody) Summary: Global variables do not work as loop operands Initial Comment: unsigned char x; unsigned char y; void do_domething_else( unsigned char row ) { // whatever... will be called once with row = 0 but not again. } void do_something( void ) { unsigned char _tmp; for (_tmp = x; _tmp < y; _tmp++) { // being called only once, not y times! do_something_else(_tmp); } void main( void ) { x = 0; y = 23; do_something(); } Declaring x or y extern in functions does not help. No warnings or errors are produced, the code generated just doesnt work properly. Doing the following will force it to work: Change: for (_tmp = x; _tmp < y; _tmp++) To: for (_tmp = x; _tmp < 23; _tmp++) or doing y=23 just before the for statement neither are work arounds to making a working program that uses global variables. SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.5.0 #1020 (May 8 2005) (UNIX) email: cla...@at... ---------------------------------------------------------------------- Comment By: Virgilio Eng. Villatora (vvillatora) Date: 2006-09-30 10:56 Message: Logged In: YES user_id=1610032 It is very critical code if you use global variable for loops... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1358533&group_id=599 |