- Timestamp:
- Jun 15, 2011, 5:27:48 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ASM/CPP2011/cpp-2011.tex
r968 r969 9 9 \usepackage{graphicx} 10 10 \usepackage[colorlinks]{hyperref} 11 \usepackage{hyphenat} 11 12 \usepackage[utf8x]{inputenc} 12 13 \usepackage{listings} … … 257 258 This function fails if and only if an internal call to \texttt{assembly\_1\_pseudoinstruction} fails: 258 259 \begin{lstlisting} 259 definition sigma0: pseudo_assembly_program260 260 definition sigma0: 261 pseudo_assembly_program $\rightarrow$ option (nat $\times$ (nat $\times$ (BitVectorTrie Word 16))) := $\ldots$ 261 262 \end{lstlisting} 262 263 263 264 We eventually lift this to functions from program counters to program counters: 264 265 \begin{lstlisting} 265 definition sigma_safe: pseudo_assembly_program266 266 definition sigma_safe: 267 pseudo_assembly_program $\rightarrow$ option (Word $\rightarrow$ Word) := $\ldots$ 267 268 \end{lstlisting} 268 269 … … 270 271 As mentioned, \texttt{sigma\_safe} can only fail if an assembly program fails to be assembled: 271 272 \begin{lstlisting} 272 definition policy_ok := $\lambda$policy. $\lambda$p. sigma_safe policy p $\neq$ None $\ldots$. 273 \end{lstlisting} 274 275 Finally, we obtain \texttt{sigma}, a map from program counters to program counters, which is guranteed not to fail, as we must provide a proof that our policy at hand is a `good policy'. 276 \begin{lstlisting} 277 definition sigma: 278 ∀p:pseudo_assembly_program. 279 ∀policy. policy_ok policy p. Word → Word 280 \end{lstlisting} 281 273 definition policy_ok := $\lambda$p. sigma_safe p $\neq$ None $\ldots$. 274 \end{lstlisting} 275 276 Finally, we obtain \texttt{sigma}, a map from program counters to program counters, which is guranteed not to fail as we internally provide a that 277 \begin{lstlisting} 278 definition sigma: pseudo_assembly_program $\rightarrow$ Word $\rightarrow$ Word := $\ldots$ 279 \end{lstlisting} 280 281 An \texttt{internal\_pseudo\_address\_map} positions in the memory of a \texttt{PseudoStatus} with a physical memory address. 282 \begin{lstlisting} 283 definition internal_pseudo_address_map := list (BitVector 8). 284 \end{lstlisting} 285 286 We use \texttt{internal\_pseudo\_address\_map}s to convert the lower internal RAM of a \texttt{PseudoStatus} into the lower internal RAM of a \texttt{Status}. 287 Notice, the MCS-51's internal RAM is addressed with a 7-bit `byte'. 288 % dpm: ugly English, fix 289 The whole of the internal RAM space is addressed with bytes: the first bit is used to distinguish between the programmer addressing low and high internal memory. 282 290 \begin{lstlisting} 283 291 axiom low_internal_ram_of_pseudo_low_internal_ram: 284 ∀M:internal_pseudo_address_map.∀ram:BitVectorTrie Byte 7.BitVectorTrie Byte 7. 285 \end{lstlisting} 286 287 CSC: no option using policy 292 internal_pseudo_address_map $\rightarrow$ BitVectorTrie Byte 7 $\rightarrow$ BitVectorTrie Byte 7. 293 \end{lstlisting} 294 A similar axiom exists for high internal RAM. 295 296 Next, we are able to translate \texttt{PseudoStatus} records into \texttt{Status} records using \texttt{status\_of\_pseudo\_status}. 297 Translating a \texttt{PseudoStatus}'s code memory requires we expand pseudoinstructions and then assemble to obtain a trie of bytes. 298 This can fail, as mentioned, in a limited number of situations, related to improper use of labels in an assembly program. 299 However, it is possible to `tighten' the type of \texttt{status\_of\_pseudo\_status}, removing the option type, by using the fact that if any `good policy' exists, assembly will never fail. 288 300 \begin{lstlisting} 289 301 definition status_of_pseudo_status: … … 291 303 \end{lstlisting} 292 304 305 After fetching an assembly instruction we must update any \texttt{internal\_pseudo\hyp{}\_address\_map}s that may be laying around. 306 This is done with the following function: 293 307 \begin{lstlisting} 294 308 definition next_internal_pseudo_address_map0: … … 296 310 \end{lstlisting} 297 311 298 CSC: no 2nd, 3rd options using policy 299 \begin{lstlisting} 300 ∀M,M',ps,s,s''. 301 next_internal_pseudo_address_map M ps = Some ... M' → 302 status_of_pseudo_status M ps = Some ... s → 303 status_of_pseudo_status M' (execute_1_pseudo_instruction (ticks_of (code_memory ... ps)) ps) = Some ... s'' → 304 ∃n. execute n s = s''. 305 \end{lstlisting} 312 Finally, we are able to state and prove our main theorem regarding 313 \begin{lstlisting} 314 lemma main_thm: 315 ∀M,M',ps,s,s''. 316 next_internal_pseudo_address_map M ps = Some ... M' $\rightarrow$ 317 status_of_pseudo_status M ps = Some ... s $\rightarrow$ 318 status_of_pseudo_status M' 319 (execute_1_pseudo_instruction 320 (ticks_of (code_memory ... ps)) ps) = Some ... s'' $\rightarrow$ 321 $\exists$n. execute n s = s''. 322 \end{lstlisting} 323 324 % ---------------------------------------------------------------------------- % 325 % SECTION % 326 % ---------------------------------------------------------------------------- % 327 \subsection{Proof of correctness} 328 \label{subsect.proof.of.correctness} 306 329 307 330 CSC: no options using policy
Note: See TracChangeset
for help on using the changeset viewer.