From: feqin f. <feq...@gm...> - 2012-12-31 04:05:22
|
Hi, Guys. I have found a weird thing, in PORT PIC14. write this C source code: ----------------------------------------------------------------------- #include"pic16f887.h" void main() { int i, temp = 0x100; for (i=0 ;i<10; i++) { temp = temp + 0x102; // this will be disappear magically. // I mean the number 0x102 will NOT be added to the temp. // if the number is other besides 0x102, everything is all right PORTA = temp; // I konwn only the low 8 bit will be used. } } ------------------------------------------------------------------- My version is 3.2.0 a call sdcc linke this -- sdcc -mpic14 -p16f887 a.c The output ASM file is: ------------------------------------------------------------------------------------------- UDL_a_0 udata r0x1000 res 1 r0x1002 res 1 r0x1003 res 1 STARTUP code 0x0000 nop pagesel __sdcc_gsinit_startup goto __sdcc_gsinit_startup _main ;Function start BANKSEL r0x1000 CLRF r0x1000 MOVLW 0x01 CLRF r0x1002 CLRF r0x1003 ;;signed compare: left < lit(0xA=10), size=2, mask=ffff _00105_DS_ BANKSEL r0x1003 MOVF r0x1003,W ADDLW 0x80 ADDLW 0x80 BTFSS STATUS,2 GOTO _00116_DS_ MOVLW 0x0a SUBWF r0x1002,W _00116_DS_ BTFSC STATUS,0 GOTO _00109_DS_ ; .line 20; "a.c" PORTA = temp; BANKSEL r0x1000 MOVF r0x1000,W BANKSEL _PORTA MOVWF _PORTA ; .line 17; "a.c" for (i=0 ;i<10; i++) BANKSEL r0x1002 INCF r0x1002,F BTFSC STATUS,2 INCF r0x1003,F GOTO _00105_DS_ _00109_DS_ RETURN end ----------------------------------------------------------------------------------------------- -- *live long and prosper..* |