Branch limitations when using includes

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Part of my job involves designing hardware and embedded software. I always use assembly language and have just moved up from 'HC05 to 'HC08 micros. I have always written my code as one long sheet of stuff and have never used "includes" that grab external listings of code.

Now, I got to thinking, with a branch instruction you are limited to branching +/- 127 so sometimes you get the "parameter out of range" error if your code is too long. If though, I included several pieces of external code would I still have this branch limitation seeing each section of code is not in a specific place? Or is it, and you have to state where it is?
 
I don't know specifically about HC08s, but I've run into similar problems with smaller PICs that have a limitation of 256 byte - 2kB memory pages. If you try to branch beyond a page boundary, you can run into problems. There are work-arounds such as explicitly loading the upper byte of the program counter before EVERY branch and RETURN instruction, but you would probably have to do that in your included code, too. If your whole program is less than the memory page size, you can issue commands to the assembler to load specific code at specific addresses and thereby prevent accidentally spilling over a page boundary.

There are a bunch of macros people have written for PICs that include things like "long goto", etc. Probbaly some of those for HC08s out there in the tubes of the inter web if you look for them.

The root of the problem is that the program counter isn't big enough to address all the program memory without resorting to paging. I ran into this problem on a project about 6 months ago and ultimately decided to go with a bigger uC ($2 higher price) that has a larger program counter so the memory isn't paged.

This sort of nit-picky stuff is why many people prefer to program in C. Programming in assembly is hard enough without keeping track of all that stuff, too.

I_F
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.