First off, Sorry for the new thread, my old free email account was 
bouncing your replies, and by chance i saw your replies through the 
archived lists.
I have since changed e-mail accounts, so there should not be any more of 
a bounce problem. (i hope)

using sdcc 2.9.0 and mcu8051ide for simulator

I am kind of new to C programming and esp the whole embedded 8051 thing.
Thank you for all of your input on this matter

Hi Putu,
 > each time the "if( a = a + 1024 )" statement is executed, the value of
 > a is increased by 1024.

Yes, thats what i want, so i can count how many K of bytes have passed.

(a==a + 1024) would be true one time if ram_start was at or below 1024 i 
believe. :)

Hi Bodo
 > if( ( a = a + 1024 ) != 0) is the same as "a" would never be 0. :)

I forgot to say that the pointer code was originally from:
http://www.esacademy.com/en/library/technical-articles-and-documents/8051-programming/using-pointers-arrays-structures-and-unions-in-8051-c-compilers.html

Something indeed is up with testing "a" in the if() statement, as i 
change the value of 1024 to something else e.g. 124, it makes "a" 
corrupt. (not count up as expected)

Now my new question is, Why would testing the value of variable "a" 
inside an if() statement change the value of "a" elsewhere?

This version i have running in the simulator.

code:

#include<8052.h>

#define RAM_START       0x2100
#define RAM_END         0x3FFF
void main(void)
{
unsigned int a=0;
xdata unsigned char *abs_ptr = (xdata unsigned char *) RAM_START; // 
Initialize pointer to RAM_START
        for(a = RAM_START; a <= RAM_END; a++)
        {
                if(a = a + 1024)
                {
                !P3_0;          // if true every K toggles led
                }
        *abs_ptr = 0x69 ;
        *abs_ptr++ ;
        P1 = a; // status of "a" variable on port P1
        }
_asm ljmp 0 _endasm; // fin.
}

------------------------------------------------------------------------------
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

Reply via email to