Is it me or stack problems, or me? :P example code:
/* SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.9.0 #5416 (Nov 19 2009) (UNIX) */ /* sdcc --code-loc 0x2000 pointer_dies.c ; cat pointer_dies.ihx > /dev/ttyS1 */ // the targets are a paulmon 8052 rev. 3 board // and a 8052 wirewrapped prototype running with the exact same results (ram at 0x2000 - 0x7FFF) // before i run code in the monitor, i fill all ram with a random value eg: 0x55 // after i compile and run this code in the paulmon monitor i hexdump from 0x2500 - 0x3FFF /* in THIS cut down example file i get only 5 bytes, the last 2 bytes are mine: ... 2500: 00 00 00 00 00 02 00 55 55 55 55 55 55 55 55 55 UUUUUUUUU 2510: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU 2520: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU 2530: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU 2540: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU ... when it should be 0x00 from 0x2500 - 0x3FFF if i lose the "if( a = a + 1024 )" test, it runs like it should. */ #include <8051.h> // in paulmon use 0x2500 to keep example code from being wiped. #define RAM_START 0x2500 #define RAM_END 0x3FFF // set to just "\r" if your terminal has cr-lf enabled. #define _NR_ "\n\r" void putchar(char c) { while(!TI); TI=0; SBUF = c; } void putstr(char *s) { char i=0; char c; while((c=*(s+(i++)))!= 0) putchar(c); // while byte is not terminator, keep sending } void init_ram() // flood ram area with 0x00 { unsigned int a=0,b=0,c=0; xdata unsigned char *abs_ptr = (xdata unsigned char *) RAM_START; // Initialize pointer to RAM_START putstr("Filling ramspace with 0x00 (Each * represents 1 KiloByte of NOP)");putstr(_NR_); for(a = RAM_START; a < RAM_END; a++) { if( a = a + 1024 ) // strangely this makes the pointer work for 21 bytes then quit at (0x2514) //a=c;if(c=c+1024) // this one works for 32 bytes then quits. { b++; putstr("* "); if(b==8) // just formats with \r\n every 8k { putstr(_NR_); b=0; } } *abs_ptr = 0x00 ; // Write 0x00 to RAM_LOCATION *abs_ptr++ ; // Make pointer point at next location in RAM } *abs_ptr--;*abs_ptr--;*abs_ptr = 0x02; // backup 2 bytes and add "ljmp 0" to make it reset if downloaded code falls through. } void main(void) { // other non relevant functions and code snipped... init_ram(); // other non relevant functions and code snipped... while(1){ putstr(_NR_);putstr("Finished, Press return to reset paulmon.");putstr(_NR_); // debugging only... _asm ljmp 0 _endasm ;// debugging only, break out of while() and return to paulmon. } } _____________________________________________________________ Get your FREE, LinuxWaves.com Email Now! --> http://www.LinuxWaves.com Join Linux Discussions! --> http://Community.LinuxWaves.com ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user