The result of translating the C++ program posrun.cpp in to assembly language can be found in posrun.s.
Many "optimizations" were then made to the assembly language. The final version of the assembly language program performs the same function as the original, but looks somewhat different. The C++ program posrunopt.cpp corresponds to the optimized assembly language in posrunopt.s.
The following table summarizes the total number of instructions, as well as the best and worst case instruction counts for executing the body of the for loop.
| total | best | worst | ||
|---|---|---|---|---|
| posrun.s | 16 | 13 | 15 | 8 + (1,2) + 2 + (0,1) + 2 |
| posrunopt.s | 11 | 6 | 10 | 3 + (1,3,5) + 2 |