On Mon, Jan 4, 2010 at 12:00 AM, Bodo Wenzel <bodowen...@web.de> wrote:
>>                       if( a = a + 1024 )      // strangely this makes the 
>> pointer work for 21 bytes
> Well, this is a bad code; do you really mean:
>
>                      if( ( a = a + 1024 ) != 0)
>
> The other proposal "(a == a + 1024)" will never be true. ;-)

Hi Bodo,
you are alright. How idiot I am :D
thank you for your point.

>
>>               *abs_ptr++ ; // Make pointer point at next location in RAM
> I think this is the culprit. This line increments the cell pointed to by
> abs_ptr, not the pointer. You surely wanted to do:
>
>              abs_ptr++;

I think *abs_ptr++ and abs_ptr++ will point into a same address,
because the presedence of ++ is higher than * operator.
so, *abs_ptr++ is equal to *(abs_ptr++) not (*abs_ptr)++.
But, I agree with Bodo, the code is not good.

I think what do you (mr_cross) want to do is some thing like this.
//code inside init_ram()
unsigned int cnt = 0;
for (a = RAM_START; a < RAM_END; a++)
{
        cnt++;
        if (cnt == 1024) //print * every 1 kB
        {
                // ... code for print * and CRLF
                
                cnt = 0;
        }
        *abs_ptr = 0x00;
        abs_ptr++;
}

just my IDR 0.02
putu

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