Specifications
Bound-T tracks the changes in SP and translates SP-relative addresses with varying offsets to
addresses relative to the SP on entry (after the BSR or JSR) with fixed offsets. The fixed offset
for a parameter is 2 or more (offset 0 refers to the return address). The fixed offset for local
variables is negative.
Bound-T does not yet support the use of frame pointers.
Return from subprogram
To return, the subprogram pops its local variables from the stack, restores the caller-save
registers from the stack, and executes RTS.
There may be more than one such return point in a subprogram.
Library subprograms that violate the calling standard
Run-time libraries sometimes contain special subprograms that are meant to be called only by
compiler-generated code and have non-standard calling sequences. No information is currently
available on this question for the GCC libraries.
6.3 The IAR calling protocol
This section sketches how Bound-T supports the procedure calling protocol used by the IAR
Systems H8/300 C compiler. This section is based on the compiler manual [7] and on
observation of compiled code.
The IAR compiler supports the native 64-kilo-octet memory space but also supports banked
code by which a certain address window can be mapped to one of several external memory
banks containing code. The calling protocol becomes more complex for banked code. At
present Bound-T does not support banked code and we discuss only the non-banked (native)
IAR calling protocol here.
The non-banked IAR calling protocol has the following features:
• The native instructions BSR/JSR and RTS are used.
• The first parameter is normally passed in a register, using R6L, R6 or R5:R6 depending on
the size of the parameter.
• Other parameters are normally passed on the stack, but the compiler option -ur can specify
more registers for parameter passing.
• Normally a function must preserve all registers (except the registers used for passing
parameters or the return value), but the compiler option -uu can specify registers that can
be trashed.
The IAR compiler options -ur and -uu are supported. If they are set to non-default values, you
must use the corresponding Bound-T command-line options to tell Bound-T which values were
used in compilation.
34 Calling Protocols Bound-T for H8/300