Hi
   I was trying to compile a small program for an 8051 variant (a test version 
of my large one) and I get strange results:
#include "P89c66x.h"

void usleep(unsigned char j)
{
 // 1 = 3.12us
 unsigned char i;
 for ( i=0;i<=j;i++);
}

void main()
{
 while(1) {
   P1=0xFE;
   usleep(100);
   P1=0xFF;
   usleep(100);
 }
}

This program blinks pin P1_0. If I compile it with the small memory model, the 
usleep function works perfectly but it does not if I use large memory model. 
Then the sleeping time is independent of the input number.

The small sleep function is:
_usleep:
        ar2 = 0x02
        ar3 = 0x03
        ar4 = 0x04
        ar5 = 0x05
        ar6 = 0x06
        ar7 = 0x07
        ar0 = 0x00
        ar1 = 0x01
        mov     r2,dpl
;       test_array.c:9: for ( i=0;i<=j;i++);
        mov     r3,#0x00
00101$:
        clr     c
        mov     a,r2
        subb    a,r3
        jc      00105$
        inc     r3
        sjmp    00101$
00105$:
        ret


The large function is the following:
_usleep:
        ar2 = 0x02
        ar3 = 0x03
        ar4 = 0x04
        ar5 = 0x05
        ar6 = 0x06
        ar7 = 0x07
        ar0 = 0x00
        ar1 = 0x01
        mov     a,dpl
        mov     dptr,#_usleep_j_1_1
        movx    @dptr,a
;       test_array.c:9: for ( i=0;i<=j;i++);
        mov     dptr,#_usleep_j_1_1
        movx    a,@dptr
        mov     r2,a
        mov     r3,#0x00
00101$:
        clr     c
        mov     a,r2
        subb    a,r3
        jc      00105$
        inc     r3
        sjmp    00101$
00105$:
        ret

I don't see anything in the code that should not work.

Thanks 
Gudjon

Ps. I will read through the P89c66x.h file and then contribute it. Thanks for 
the nice software :)

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to