From: Olgierd E. <ol...@te...> - 2006-04-26 23:48:48
|
Ok, then the problem was not to link with the crtX0.o file, I didn't know about what the crt0 files were for, it's not in the manual. Thanks a lot Olgierd On Thu, 2006-04-27 at 02:11 +0300, Vangelis Rokas wrote: > ----- Original Message ----- > From: "Olgierd Eysymontt" <ol...@te...> > To: <sdc...@li...> > Subject: Re: [Sdcc-user] interrupt routines > > > >I don't fully understand how the indirect addressing is managed by SDCC, > > The example you mention has nothing to do with indirect addressing! PIC16 > port uses FSR0 for indirect addressing while reserves FSR1 for stack pointer > and FSR2 for frame pointer. > > > I've made a small program that does nothing but calling a subroutine > > that does nothing, but shows how the FSRx registers are uses, the code > > is : > > > > <-- init stuff --> > > void main() { > > setup_ini(); > > while(1){ > > delay100ktcy(100); > > } > > > > } > > > > void setup_ini(){ > > } > > > > The ASM generated by SDCC is : > > > > <--imported registers --> > > > > ;-------------------------------------------------------- > > ; public variables in this module > > ;-------------------------------------------------------- > > global _addr > > global _stack > > global _stack_end > > global _setup_ini > > global _main > > ;-------------------------------------------------------- > > ; Equates to used internal registers > > ;-------------------------------------------------------- > > FSR1L equ 0xfe1 > > FSR2L equ 0xfd9 > > POSTDEC1 equ 0xfe5 > > PREINC1 equ 0xfe4 > > > > udata_test_1_leds_0 udata > > _addr res 1 > > > > > > ustat_test_1_leds_00 udata 0X0200 > > _stack res 99 > > _stack_end res 1 > > > > ;-------------------------------------------------------- > > ; interrupt vector > > ;-------------------------------------------------------- > > > > ;-------------------------------------------------------- > > ; global & static initialisations > > ;-------------------------------------------------------- > > ; I code from now on! > > ; ; Starting pCode block > > S_test_1_leds__main code > > _main: > > ; .line 36; test_1_leds.c setup_ini(); > > CALL _setup_ini > > _00106_DS_: > > ; .line 41; test_1_leds.c delay100ktcy(100); > > MOVLW 0x64 > > CALL _delay100ktcy > > GOTO _00106_DS_ > > RETURN > > > > ; ; Starting pCode block > > S_test_1_leds__setup_ini code > > _setup_ini: > > ; .line 46; test_1_leds.c void setup_ini(){ > > MOVFF FSR2L, POSTDEC1 > > MOVFF FSR1L, FSR2L > > ; .line 52; test_1_leds.c } > > MOVFF PREINC1, FSR2L > > RETURN > > > > > > > > ; Statistics: > > ; code size: 30 (0x001e) bytes ( 0.02%) > > ; 15 (0x000f) words > > ; udata size: 101 (0x0065) bytes ( 2.74%) > > ; access size: 0 (0x0000) bytes > > > > > > end > > > > > My question is where are initialized the FSR2L (frame pointer) and other > > FSRxx registers ?? because after a reset their content are unknown. > > FSR1 and FSR2 are initialized in device/lib/pic16/startup/crt0*.o files. > These hook the RESET vector so the gain control when the uC powers up, > resets, etc... > crt0.c simply initializes stack and frame pointer > crt0i.c initializes stack/frame pointers and sets up variables with > initializers > crt0iz.c is same as crt0i.c first it sets all RAM memory to zeroes (0) > > > > I have another question, sorry for my ignorance, I've never programmed > > ASM before, so what is the frame pointer used to ? > > When passing variables to a function, these are stored temporarly on stack. > Stack pointer after entering such a function might be further changed to > account > for registers that are used locally in the function. So, there should be a > pointer to > point at function arguments regardless the state of the stack pointer. See > hot more > complex functions work and you'll understand the purpose of frame pointer. > > Normally, in an empty function ( setup_ini() ) no FSR2 initialization code > should be > emitted at all. Is setup_ini() really empty? > > regards, > Vangelis > > > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user |