This thesis explores the use of program transformation tools in the analysis and compilation of programs for embedded systems. The intrinsic difficulty in programming for these small-scale systems arises from the discrete effects that executing an instruction produces. In larger scale systems these effects are masked by the large number of instructions executed to perform a typical action.
The central claim of this thesis is that program transformation tools can aid the programmer in understanding and controlling these effects and therefore reduce the complexity of the problem; both in difficulty and in scale.
We have investigated this method on two cases that are typical of the problems in embedded software development; software timing and precision. In the former case we have developed a novel abstract interpretation that computes the timing distance between locations in a program binary. Our new technique for analysing the structure of a program can then be combined with the set of timing distances to generate models of the timing behaviour of the program. We demonstrate this work in the context of verifying legacy applications.
In the later case we look at the problem of roundoff error in software. Given the small datasizes on typical embedded processors, the programmer is normally responsible for handling the rounding of values and ensuring that datatypes are sufficiently large to represent data without an error. We present a domain specific language that allows this property to be expressed directly. Analysis of how to propagate the variable precisions in this domain is investigated, and we conclude with a technique to automatically generate a compiler for the domain.