# stm8¶

Stm8 support.

http://www.st.com/stm8

## Implementation¶

Since there are so few registers, one possible approach is to emulate registers in the first 16 or 32 bytes of ram. We can then use these ram locations as ‘registers’ and do register allocation and instruction selection using these ‘registers’. This way, we treat the stm8 as a risc machine with many registers, while in reality it is not.

## Calling conventions¶

There is not really a standard calling convention for the stm8 processor.

Since the stm8 has only few registers, a calling convention must place most arguments on stack.

class ppci.arch.stm8.Stm8Arch(options=None)

STM8 architecture description.

determine_arg_locations(arg_types)

Calling convention in priority order:

• Pointers in index registers;
• 16-bit variables in index registers;
• 8-bit variables in accumulator register first, afterwards in index registers.
determine_rv_location(ret_type)

Determine the location of a return value of a function given the type of return value

gen_call(frame, label, args, rv)

Generate instructions for a function call.

gen_epilogue(frame)

Generate instructions for the epilogue of a frame.

Parameters: frame – the function frame for which to create a prologue
gen_function_enter(args)

Generate code to extract arguments from the proper locations

The default implementation tries to use registers and move instructions.

Parameters: args – an iterable of virtual registers in which the arguments must be placed.
gen_prologue(frame)

Generate instructions for the epilogue of a frame.

Parameters: frame – the function frame for which to create a prologue