Help on alignment with GNU Assembler and H8S/2117 (2600 Family)

Hello,

It's the first time that I use an H8 microprocessor. I'm writing a program in H8 assembler (no C code at all) and I'm using GNU h8300-elf-as and h8300-elf-ld.

This processor needs alignment on even addresses for targets of jumps, branches, and for moving words and dwords.

Aligning data seems to be very easy: I put a ".balign 2" directive just before any word or dword data, to be sure they are aligned to an even address.

For the assembler code, should I manually put ".balign 2" directives just before every label definition? It's a bit crasy, don't you think? Is there a way to ask the assembler/linker to automatically align all the branch targets to even addresses?

Thank you in advance

Panino

Reply to
paninocolsalame
Loading thread data ...

No define the data/bss sections on even boundarys, use definitions of types (.byte, .word, .long) to reserve the space as in any assembler.

Yes.

Look at example code modules, you must have seen something.

You might find my sig links helpful.

--
Paul Carpenter          | paul@pcserviceselectronics.co.uk
    PC Services
 Timing Diagram Font
  GNU H8 - compiler & Renesas H8/H8S/H8 Tiny
 For those web sites you hate
Reply to
Paul Carpenter

Sounds like the safe thing to do. Of course, if you have several words/dwords in sequence, there is no need to use .balign more than once, at the start.

This is not necessary. Since all instructions are 16 or 32 bits, if your code (subroutine) starts on an even address, all following instructions and labels will have an even address.

And not needed, see above.

Only if you use assembler directives to insert an odd number of (data) octets in between instructions could you get an odd code address. And I expect the assembler will report this error (haven't tried it, though).

HTH,

--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .
Reply to
Niklas Holsti

Thank you Niklas. This is the information that I need! My main problem was how to have code alignment under control.

I'm porting a big assembler file containing constant data between the code. So all constants require an .align after them, not only just before them.

Thank you even to Paul: I'll take a look at the links you wrote.

I'll take the liberty to disturb you again on this newsgroup, in case I have other questions.

Thank you again

Panino

Reply to
paninocolsalame

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.