PDA

View Full Version : Changing position of program code



aerostar
- 12th December 2006, 14:21
I want to start some code at a page boundary, I cannot see a command in PBPRO to do this, I am using PB2.43, 16f876a, and there does not seem to be anything after using the search in this and the old list. Perhaps I am not putting in the correct words !.

eg code
org 1000h
code

mister_e
- 12th December 2006, 14:37
It's kinda dangerous but you can use

@ ORG 1000h
your code here

sayzer
- 12th December 2006, 17:33
Why someone would want to start a code at page boundary?

May be I need to learn that.

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

aerostar
- 12th December 2006, 19:14
Thanks for the reply, I will try it out tomorrow.

I am trying to debug some code which appears to fall over around the 1000h boundary, so by making some of the code start after the boundary and not cross it I can then perhaps make a more educated guess as to what I have done wrong.

keithdoxey
- 12th December 2006, 20:17
Thanks for the reply, I will try it out tomorrow.

I am trying to debug some code which appears to fall over around the 1000h boundary, so by making some of the code start after the boundary and not cross it I can then perhaps make a more educated guess as to what I have done wrong.

Do you have any BRANCH instructions in there ?

skimask
- 12th December 2006, 20:21
Thanks for the reply, I will try it out tomorrow.

I am trying to debug some code which appears to fall over around the 1000h boundary, so by making some of the code start after the boundary and not cross it I can then perhaps make a more educated guess as to what I have done wrong.


If you're getting the 'cross page boundary' warning, that's all it is... a warning. PBP takes care of business for you.
Nothing to worry about.
JDG

Archangel
- 12th December 2006, 23:44
Why someone would want to start a code at page boundary?

May be I need to learn that.

---------------------
I gotta parrot sayzer, why is that important? Are you trying to find out what code to leave off in order to use a pic with less space?
JS.


Curiousity killed the cat
Satisfaction brought him back.

aerostar
- 13th December 2006, 10:03
I know about the compiler warnings. I have now re-arranged some code and removed a subroutine, it is now 4.7k and does not have problems.
Thanks for the comments.

Acetronics2
- 13th December 2006, 11:50
Hi, Aerostar

I've already noted some troubles as you describe ... diseappearing when subs are re-arranged !!!

Generally when subroutines are placed at the end of the program , not so far from boundary limits ... ( If - Then tests not working i.e. )

I wrote a thread about that in those columns ... but no definitive answer !!!

Can't find a satisfying explanation to that ...

Alain

skimask
- 13th December 2006, 12:52
Hi, Aerostar

I've already noted some troubles as you describe ... diseappearing when subs are re-arranged !!!

Generally when subroutines are placed at the end of the program , not so far from boundary limits ... ( If - Then tests not working i.e. )

I wrote a thread about that in those columns ... but no definitive answer !!!

Can't find a satisfying explanation to that ...

Alain


Now that's different...I've always put my sub's at the beginning of the program and jumped over them and haven't had a problem. Huh... even more unsatisfying isn't it?
JDG

Ioannis
- 14th December 2006, 05:48
On older version of PBP there was an issue with the placement of sub's. I think it was prior to 2.32. After that there was no limit as to where one can put his sub's. BUT, I found that rearranging the subs, there was a great improvment on the final code size.

I suppose this is explained considering the boundary limits and the asm commands used by the compiler.

Ioannis

sayzer
- 14th December 2006, 07:17
So in this case, where do we put the subs then?

Based on what criteria do we arrange the subs?


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

Ioannis
- 14th December 2006, 07:30
Hi Sayzer. Well, now there is no official directive as to where is better placed a sub. According to old practice, on top. But this does not affect in any way the execution.

I only pointed out that if one has 5 sub's for example, and have different sizes, rearranging the order of them is affecting the final code size. I think is because a bigger sub might fall between two pages while others won't.

After a little experimenting you can find that your code might reduce up to 20% or more! Also if you change your variables to be placed on BANK0 also may help. Especially if there are arrays in the program. I had a program reduced from 7540 bytes to 6200 using the above!

Ioannis

Acetronics2
- 14th December 2006, 08:49
Hi, Sayzer

You meet here The big Basic Programmer's lack of project definition ...

Basic enables you lots of jumps and come back ... But the first thing is to write a neat logical organigram ...

Like It was to be done with "old dinausaurs " programming langages like Fortran ...

So, the thing to do is put the job in a correct order to have the minimum GOTOs and GOSUBs ...

No so easy ... when the project grows more and more !!!

Alain

Ioannis
- 14th December 2006, 09:03
Just a note: what I described at #13 has nothing to do with GOTO's. Just the order of the sub's. If this is going on top of the other has an immediate impact on code size produced.

Ioannis

Archangel
- 14th December 2006, 17:37
Hi Ioannis,acetronics,
I knew aerostar had a reason, now I know why. I learned something again today! Thanks,
JS


edit
FORTRAN ? Now we're talkin OLD I remember studying my dad's fortran manuals in 1968? I think Dr. Peabody used that to program the wayback machine!

sayzer
- 14th December 2006, 18:08
Hi, Sayzer

You meet here The big Basic Programmer's lack of project definition ...

Basic enables you lots of jumps and come back ... But the first thing is to write a neat logical organigram ...

Like It was to be done with "old dinausaurs " programming langages like Fortran ...

So, the thing to do is put the job in a correct order to have the minimum GOTOs and GOSUBs ...

No so easy ... when the project grows more and more !!!

Alain


I always thought that programming structure addresses a programmer who is looking at the code from outside. So that when you write a code, another programmer from outside can understand your coding and logic relatively easier.

If you write a code that is mixed all over, a new comer will not understand the logic flow.

But, despite all, now, I learn that the structure also has a direct effect on the code size.

I just made some tests, moved the subs around in a code.
The code size indeed drops.


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

Ioannis
- 15th December 2006, 07:34
I know what I will suggest is not much of a help, but generally the big sub's is better to be placed on top of each memory page. If you cannot find how long a sub may take, then compile it in a new program file, after compilation check the length and move the sub to a better position at the final program.

Then the rest of the page can be filled with a smaller sub.

If anyone has a better suggestion, please, one step forward.

Ioannis