Next: i960, Up: Machine Dependent

### 4.1 `ld` and the H8/300

For the H8/300, `ld` can perform these global optimizations when you specify the ‘`--relax`’ command-line option.

relaxing address modes
  `ld` finds all `jsr` and `jmp` instructions whose targets are within eight bits, and turns them into eight-bit program-counter relative `bsr` and `bra` instructions, respectively.

synthesizing instructions
  `ld` finds all `mov.b` instructions which use the sixteen-bit absolute address form, but refer to the top page of memory, and changes them to use the eight-bit address form. (That is: the linker turns ‘`mov.b `@`aa:16`’ into ‘`mov.b `@`aa:8`’ whenever the address aa is in the top page of memory).

  `ld` finds all `mov` instructions which use the register indirect with 32-bit displacement addressing mode, but use a small displacement inside 16-bit displacement range, and changes them to use the 16-bit displacement form. (That is: the linker turns ‘`mov.b `@`d:32,ERx`’ into ‘`mov.b `@`d:16,ERx`’ whenever the displacement d is in the 16 bit signed integer range. Only implemented in ELF-format ld).

bit manipulation instructions
  `ld` finds all bit manipulation instructions like `band, bclr, biand, bild, bior, bist, bixor, bld, bnot, bor, bset, bst, btst, bxor` which use 32 bit and 16 bit absolute address form, but refer to the top page of memory, and changes them to use the 8 bit address form. (That is: the linker turns ‘`bset #xx:3,`@`aa:32`’ into ‘`bset #xx:3,`@`aa:8`’ whenever the address aa is in the top page of memory).
system control instructions
  `ld` finds all `ldc.w, stc.w` instructions which use the 32 bit absolute address form, but refer to the top page of memory, and changes them to use 16 bit address form. (That is: the linker turns ‘`ldc.w `@`aa:32,ccr`’ into ‘`ldc.w `@`aa:16,ccr`’ whenever the address aa is in the top page of memory).