diff options
Diffstat (limited to 'thesis/storing-pc.tex')
-rw-r--r-- | thesis/storing-pc.tex | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/thesis/storing-pc.tex b/thesis/storing-pc.tex index d3fc474..dda32ab 100644 --- a/thesis/storing-pc.tex +++ b/thesis/storing-pc.tex @@ -108,6 +108,10 @@ We therefore need a fast, small Thumb alternative for the ARM code. \subsection{Solution} \label{sec:storing-pc:solution} +Recall from \cref{sec:storing-pc:intro} that we meet two issues when generating Thumb code. +First, that \ual{pc} cannot be the first operand of a \ual{str} instruction; + second, that the value read for the program counter is word-aligned while the read instruction may be halfword-aligned. + To solve the first problem, we need to first move \ual{pc} to an auxiliary register, and then push that on the stack. We then get, for the example from \texttt{armstartup.s:540-2}: @@ -160,7 +164,7 @@ Assuming the worst case, that all instructions in the jump block are wide, we ne As a benchmark, the Clean compiler has 41,006 jumps of this kind in 1,253,978 instructions, or approximately 3.27\%. The four extra bytes in Thumb mean a size increase of $41006\cdot4\approx160$KiB on the 5.3MiB file, an increase of 3.00\%. -As for the time complexity: every jump requires an extra instruction cycle. +As for the time complexity: every subroutine call requires an extra instruction cycle. In particular, every reduction needs an extra cycle. It is hard to tell what effect this has on Clean programs in general, and it may well be very dependent on the kind of program. |