>> (* please forgive the top-post *)

>> Arif --

>> >>>   P1 = 0xFF; //ALL LEDs off
>> >>>   P1 &= (0x1<<4); //LED 4 ON


>> Try:
>>     P1 &= ~(1<<4) ;    // LED 4 on.

>> your code was turning off LED4.  The tilde (~) creates a bitmask that
>> will preserve the P1 bits.  They will stay off.


>> well, it is just a guess.  I am more of a Z80 programmer....


>> HTH,
>> *the other brian



---------------------------------------------------

Hello brian,

Thanks for your response.

Ah! The typo. Your observation is right. But this mistake was only in my email. 
The code has the correct expression (i.e. P1 &= ~(1<<4)).

Also, I checked the hello390.asm file and the assembly code seems as expected
----------------------------------------------------------------------------------
__reset_vect:
        ljmp    __sdcc_gsinit_startup
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
        .area HOME    (CODE)
        .area GSINIT  (CODE)
        .area GSFINAL (CODE)
        .area GSINIT  (CODE)
__sdcc_gsinit_startup:
        mov     sp,#__start__stack - 1
        lcall   __sdcc_external_startup
        mov     a,dpl
        jz      __sdcc_init_data
        ljmp    __sdcc_program_startup
----------------------------------------------------------------------------------


Here, after reset __sdcc_gsinit_startup is called and then after adjusting the 
stack pointer; __sdcc_external_startup is called.

----------------------------------------------------------------------------------
;        function _sdcc_external_startup
;       -----------------------------------------
__sdcc_external_startup:
        ar2 = 0x02
        ar3 = 0x03
        ar4 = 0x04
        ar5 = 0x05
        ar6 = 0x06
        ar7 = 0x07
        ar0 = 0x00
        ar1 = 0x01
;       hello390.c:8: WTST = 0x00;
;       genAssign: resultIsFar = FALSE
        mov     _WTST,#0x00
;       hello390.c:9: CKCON = 0x01;
;       genAssign: resultIsFar = FALSE
        mov     _CKCON,#0x01
;       hello390.c:12: P1 = 0xFF;       
;       genAssign: resultIsFar = FALSE
        mov     _P1,#0xFF
;       hello390.c:13: P1 &= ~(0x1<<4);
        anl     _P1,#0xEF
--------------------------------------------------------------------------------------

The above shown code for __sdcc_external_startup seems correct too. If the 
control reaches here correctly, the LED must start to glow but it doesn't.
So it seems the control is not reaching inside __sdcc_external_startup.

Only suspicious thing which I can see is that __sdcc_external_startup is not in 
HOME seg (0x00-0x4D == 77 bytes) instead it is in CODE seg (s_CSEG == 0x008D).


Thanks
Arif



------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to