CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Does CCS compiler always keep reset vector clear?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ron
Guest







Does CCS compiler always keep reset vector clear?
PostPosted: Thu Nov 07, 2002 9:03 am     Reply with quote

Hello,

Does the compiler always keep the four addresses 0000 - 0003 clear, so I can use my bootload code with any program I make? (PIC18f452)

I have a bootloader which has some code at the reset vector. Normally, the compiler seems to place a goto instruction to the main loop at addresses 0000 - 0003.

But is this always the only code at these four addresses 0000 - 0003? In that case I can safely use my bootload code with any program I make. For the 'goto main' instruction can be easily copied to another location and be run from there. (reset-vector re-location)

Any comments would be appreciated,
Regards,
Ron
___________________________
This message was ported from CCS's old forum
Original Post ID: 8652
Ivar Johnsrud
Guest







Re: Does CSS compiler always keep reset vector clear?
PostPosted: Thu Nov 07, 2002 12:56 pm     Reply with quote

The bootloader is moving the two-four first instructions
to another location, so the bootloaders goto wont get
overwritten. If it relocates 2,3 or 4 instructions depends
on how the hex file looks like. The bootloader I have
written is searching for a goto instruction in the reset
vector, and relocates everything before and including the
goto instruction.

-Ivar

:=Hello,
:=
:=Does the compiler always keep the four addresses 0000 - 0003 clear, so I can use my bootload code with any program I make? (PIC18f452)
:=
:=I have a bootloader which has some code at the reset vector. Normally, the compiler seems to place a goto instruction to the main loop at addresses 0000 - 0003.
:=
:=But is this always the only code at these four addresses 0000 - 0003? In that case I can safely use my bootload code with any program I make. For the 'goto main' instruction can be easily copied to another location and be run from there. (reset-vector re-location)
:=
:=Any comments would be appreciated,
:=Regards,
:=Ron
___________________________
This message was ported from CCS's old forum
Original Post ID: 8662
Ron
Guest







Re: Does CSS compiler always keep reset vector clear?
PostPosted: Fri Nov 08, 2002 9:16 am     Reply with quote

:=The bootloader I have
:=written is searching for a goto instruction in the reset
:=vector, and relocates everything before and including the
:=goto instruction.

Yeah, alright, mine too. But what if the reset vector has other instructions than a goto in it? If this is the case, those instructions cannot be re-located, because other parts of the program expect these instructions around the reset vector. (e.g. address 0002, or 0006).

So my question still stands: Is there a possibility for the compiler to generate other code at the reset vector than a goto main instruction?

Any comments would be appreciated.

Best regards,
Ron
___________________________
This message was ported from CCS's old forum
Original Post ID: 8686
Tomi
Guest







Re: Does CSS compiler always keep reset vector clear?
PostPosted: Fri Nov 08, 2002 11:54 am     Reply with quote

The Interrupt Handler starts at 0x0004 word address. So you have max. 4 instructions to do something PLUS step over the IT handler(s). A correct "long jump" is 3 instructions (load upper address word into W reg, store W reg into PCLATH and the GOTO itself) for 16F87X...
So you could be sure about GOTO main.


:=So my question still stands: Is there a possibility for the compiler to generate other code at the reset vector than a goto main instruction?
:=
:=Any comments would be appreciated.
:=
:=Best regards,
:=Ron
:=
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8695
Ron
Guest







Re: Does CSS compiler always keep reset vector clear?
PostPosted: Mon Nov 11, 2002 2:49 am     Reply with quote

Thanks Tomi,

You are right there's not much space for other code. Although for the 18f452 things are a bit different:

A GOTO is only 2 instructions long. So in theory there is room for 2 GOTO's. (or 1 GOTO and 2 other instructions, if no interrupts are used. I don't know if the compiler would use interrupt vector location for other purposes, if no interrupts are used)

Therefore I'm not 100\% sure of the reset vector area to be clean of other instructions. That's why I asked.

Best regards,
Ron

:=The Interrupt Handler starts at 0x0004 word address. So you have max. 4 instructions to do something PLUS step over the IT handler(s). A correct "long jump" is 3 instructions (load upper address word into W reg, store W reg into PCLATH and the GOTO itself) for 16F87X...
:=So you could be sure about GOTO main.
:=
:=
:=:=So my question still stands: Is there a possibility for the compiler to generate other code at the reset vector than a goto main instruction?
:=:=
:=:=Any comments would be appreciated.
:=:=
:=:=Best regards,
:=:=Ron
:=:=
:=:=
:=:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8745
Ron
Guest







Re: One solution
PostPosted: Tue Nov 12, 2002 2:10 am     Reply with quote

I learned from CSS that it is possible to change the reset vector:

Use:

#Build(reset=0x200) [for example]

Best regards,
Ron

:=Hello,
:=
:=Does the compiler always keep the four addresses 0000 - 0003 clear, so I can use my bootload code with any program I make? (PIC18f452)
:=
:=I have a bootloader which has some code at the reset vector. Normally, the compiler seems to place a goto instruction to the main loop at addresses 0000 - 0003.
:=
:=But is this always the only code at these four addresses 0000 - 0003? In that case I can safely use my bootload code with any program I make. For the 'goto main' instruction can be easily copied to another location and be run from there. (reset-vector re-location)
:=
:=Any comments would be appreciated,
:=Regards,
:=Ron
___________________________
This message was ported from CCS's old forum
Original Post ID: 8778
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group