If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
Typically, relocatable code is more compact due to smaller relative program counter jumps, which can be coded in most cases directly in the assembly code (no additional operands needed). This part of code can be placed anywhere (moveable code).
Absolute branching needs more operand code size (jump position). Code is not moveable and needs to be placed at particular address.
Ignore that link, that is nonsense, you are programming a PIC. So, the deal is very simple, yet very powerful. Relocatable code is nothing else than an object module that can be linked with others using a linker. Microchip provides a linker for using relocatable code as well as templates for all their microcontrollers. What are the advantages?
1. You can write and debug a piece of code and use it many times without the need for debugging it again.
2. All the ram memory stuff in the PIC is handled automatically and a map file is generated for you. So, say you want to allocate memory for a circular buffer or any chunk of data, then the only thing you have to do is tell the linker to do so. For instance if you want to reserve 16 bytes for a buffer you can do it like this: buffer RES 16
That is, instead of allocating every byte separately.
3. The linker has many useful macros, for instance, instead of figuring out in which bank your variable is and then switching banks with the STATUS bits, it is possible to do like this: banksel Var
The linker will find out the proper bank and insert a macro accordingly.
4. you can create libraries of related modules for reusing them when needed.
5. when using routines from Microchip or from anywhere else, you don't have to worry about their memory allocation because if it fails the linker will issue a warning.
There used to be a very good starting tutorial at the Microchip website, but I don't know if they still have it.
In short, the learning curve is a bit steeper, but the advantages and benefits so many that I don't even know why the keep the absolute code thingy anymore.
Let me know if you get stuck,
Regards
R.A.
Typically, relocatable code is more compact due to smaller relative program counter jumps, which can be coded in most cases directly in the assembly code (no additional operands needed). This part of code can be placed anywhere (moveable code).
Absolute branching needs more operand code size (jump position). Code is not moveable and needs to be placed at particular address.
Aziz
Nonsense, stop quoting wikipedia on matters you know nothing about. From the same article you are quoting:
"Position-independent code can be copied to any memory location without modification and executed, unlike relocatable code, which requires special processing by a link editor or program loader to make it suitable for execution at a given location."
position-independent code NOT EQUAL TO relocatable code
you missed the part about "link editor" or "program loader".
Ignore that link, that is nonsense, you are programming a PIC. So, the deal is very simple, yet very powerful. Relocatable code is nothing else than an object module that can be linked with others using a linker. Microchip provides a linker for using relocatable code as well as templates for all their microcontrollers. What are the advantages?
1. You can write and debug a piece of code and use it many times without the need for debugging it again.
2. All the ram memory stuff in the PIC is handled automatically and a map file is generated for you. So, say you want to allocate memory for a circular buffer or any chunk of data, then the only thing you have to do is tell the linker to do so. For instance if you want to reserve 16 bytes for a buffer you can do it like this: buffer RES 16
That is, instead of allocating every byte separately.
3. The linker has many useful macros, for instance, instead of figuring out in which bank your variable is and then switching banks with the STATUS bits, it is possible to do like this: banksel Var
The linker will find out the proper bank and insert a macro accordingly.
4. you can create libraries of related modules for reusing them when needed.
5. when using routines from Microchip or from anywhere else, you don't have to worry about their memory allocation because if it fails the linker will issue a warning.
There used to be a very good starting tutorial at the Microchip website, but I don't know if they still have it.
In short, the learning curve is a bit steeper, but the advantages and benefits so many that I don't even know why the keep the absolute code thingy anymore.
Let me know if you get stuck,
Regards
R.A.
gwzd,
now this is really helpful. I did download the linker, but had not yet enough confidence to look at it. I will now. Your advice is encouraging.
The "Low Pin Count Demo Board" comes with a tutorial, but what do I do when its code causes an error message with the simulator?
The learning curve must feel steeper to some than to others.
At least I am old enough to be able to blame old age, ha, ha, ha.
Ignore that link, that is nonsense, you are programming a PIC. So, the deal is very simple, yet very powerful. Relocatable code is nothing else than an object module that can be linked with others using a linker. Microchip provides a linker for using relocatable code as well as templates for all their microcontrollers. What are the advantages?
1. You can write and debug a piece of code and use it many times without the need for debugging it again.
2. All the ram memory stuff in the PIC is handled automatically and a map file is generated for you. So, say you want to allocate memory for a circular buffer or any chunk of data, then the only thing you have to do is tell the linker to do so. For instance if you want to reserve 16 bytes for a buffer you can do it like this: buffer RES 16
That is, instead of allocating every byte separately.
3. The linker has many useful macros, for instance, instead of figuring out in which bank your variable is and then switching banks with the STATUS bits, it is possible to do like this: banksel Var
The linker will find out the proper bank and insert a macro accordingly.
4. you can create libraries of related modules for reusing them when needed.
5. when using routines from Microchip or from anywhere else, you don't have to worry about their memory allocation because if it fails the linker will issue a warning.
There used to be a very good starting tutorial at the Microchip website, but I don't know if they still have it.
In short, the learning curve is a bit steeper, but the advantages and benefits so many that I don't even know why the keep the absolute code thingy anymore.
Let me know if you get stuck,
Regards
R.A.
gwzd,
now this is really helpful. I did download the linker, but had not yet enough confidence to look at it. I will now. Your advice is encouraging.
The "Low Pin Count Demo Board" comes with a tutorial, but what do I do when its code causes an error message with the simulator?
The learning curve must feel steeper to some than to others.
At least I am old enough to be able to blame old age, ha, ha, ha.
Tinkerer,
don't be afraid it's not going to explode. Download the MPLAB IDE from Microchip's website if you already don't have it, use the template for the mcu you are intending to use as the source file. Don't forget to include in the project the linker script and the header. If you don't know how to do that let me know so I can give you a hand.
Don't worry about the simulator, it works fine with relocatable code as well.
About the age, what we have lost with the passed years in eyesight and breath we have gained in patience and perseverance. So, I wouldn't be too worried about it, the idea is clear and the benefits many.
Let me know if I can help you.
Regards,
R.A.
Is this circuit supposed to function? Does it really discriminate between iron and gold?
Monolith
Yes it works, I tested it on the breadboard. Does it work in the field? I say add the peripherals and it will.
Does it discriminate between gold and iron. Yes it discriminates perfectly for coins rings, nails, cannon balls etc.
For some strange reason it classifies gold foil as FE. I am talking of the kind of gold foil used for gilding. It does detect the 5 miligram gold foil at several inches, but in this instance the discrimination does not work.
Tinkerer
I would buy a couple of boards Carl.
this sounds interesting BW.
Been thinking about what else has not been done or thought of yet and here you answer my question. Actually had the thought about this this morning on the way to work. Not what you are suggesting though. Thanks for thinking outside of the Box.
RayNM
Comment