Changeset 1001 for src/ASM/CPP2011
- Timestamp:
- Jun 20, 2011, 5:26:31 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ASM/CPP2011/cpp-2011.tex
r1000 r1001 158 158 \begin{displaymath} 159 159 \begin{array}{r@{\qquad}r@{\quad}l@{\;\;}l@{\qquad}l} 160 \text{1:} & \mathtt{ 0x000} & \texttt{LJMP} & \texttt{0x100} & \text{\texttt{;; Jump forward 256.}} \\160 \text{1:} & \mathtt{(0x000)} & \texttt{LJMP} & \texttt{0x100} & \text{\texttt{;; Jump forward 256.}} \\ 161 161 \text{2:} & \mathtt{...} & \mathtt{...} & & \\ 162 \text{3:} & \mathtt{ 0x0FA} & \texttt{LJMP} & \texttt{0x100} & \text{\texttt{;; Jump forward 256.}} \\162 \text{3:} & \mathtt{(0x0FA)} & \texttt{LJMP} & \texttt{0x100} & \text{\texttt{;; Jump forward 256.}} \\ 163 163 \text{4:} & \mathtt{...} & \mathtt{...} & & \\ 164 \text{5:} & \mathtt{0x100} & \texttt{LJMP} & \texttt{0x100} & \text{\texttt{;; Jump forward 256.}} \\ 165 \text{6:} & \mathtt{...} & \mathtt{...} & & \\ 166 \text{7:} & \mathtt{0x1F9} & \texttt{LJMP} & \texttt{-0x300} & \text{\texttt{;; Arbitrary instruction.}} \\ 164 \text{5:} & \mathtt{(0x100)} & \texttt{LJMP} & \texttt{0x-100} & \text{\texttt{;; Jump backward 256.}} \\ 167 165 \end{array} 168 166 \end{displaymath} … … 170 168 171 169 As our example shows, given an occurence $l$ of an \texttt{LJMP} instruction, it may be possible to shrink $l$ to an occurence of an \texttt{SJMP}---consuming fewer bytes of code memory---provided we can shrink any \texttt{LJMP}s that exist between $l$ and its target location. 172 In particular, if we can somehow shrink the \texttt{LJMP} occurring at line 5, the \texttt{LJMP}s occurring at lines 1 and 3 above may both be replaced by \texttt{SJMP}s, provided that \emph{both} jumps at 1 and 3 are replaced at the same time. 170 In particular, if we wish to shrink the \texttt{LJMP} occurring at line 1, then we must shrink the \texttt{LJMP} occurring at line 3. 171 However, to shrink the \texttt{LJMP} occurring at line 3 we must also shrink the \texttt{LJMP} occurring at line 5, and \emph{vice versa}. 172 173 Further, consider what happens if, instead of appearing at memory address \texttt{0x100}, the instruction at line 5 instead appeared \emph{just} beyond the size of code memory, and all other memory addresses were shifted accordingly. 174 Now, in order to be able to successfully load our program into the MCS-51's code memory, we are \emph{obliged} to shrink the \texttt{LJMP} occurring at line 5. 175 That is, the shrinking process is not just related to optimisation, but also the completeness of the assembler. 176 173 177 Thinking more, it is easy to imagine knotty, circular configurations of jumps developing, each jump occurrence only being shrinkable if every other is. 174 178 Finding a solution to this `shrinking jumps' problem then involves us finding a method to break any vicious circularities that develop. … … 286 290 | long_jump: jump_length. 287 291 \end{lstlisting} 288 A \texttt{jump\_expansion\_policy} is a map from \texttt{Word}sto \texttt{jump\_length}s, implemented as a trie.292 A \texttt{jump\_expansion\_policy} is a map from pseudo program counters (implemented as \texttt{Word}s) to \texttt{jump\_length}s, implemented as a trie. 289 293 Intuitively, a policy maps positions in a program (indexed using program counters implemented as \texttt{Word}s) to a particular variety of jump. 290 294 \begin{lstlisting} … … 293 297 Next, we require a series of `sigma' functions. 294 298 These functions map assembly program counters to their machine code counterparts, establishing the correspondence between `positions' in an assembly program and `positions' in a machine code program. 295 At the heart of this process is \texttt{sigma0} which traverses an assembly program building maps from p rogram counter to program counter.299 At the heart of this process is \texttt{sigma0} which traverses an assembly program building maps from pseudo program counters to program counters. 296 300 This function fails if and only if an internal call to \texttt{assembly\_1\_pseudoinstruction} fails: 297 301 \begin{lstlisting}
Note: See TracChangeset
for help on using the changeset viewer.