next up previous contents
Next: Modifying and extending the Up: Adding 32-bit processing Previous: Adding 32-bit processing

Adding additional addressing modes and the SIB byte

The instruction format for the Intel386 is shown in Figure 3.2[1]. The major change from the format for Sim286 is that a new byte, the SIB byte, is now a part of the instruction format. The SIB byte encodes an additional 32 forms of addressing available for each instruction. Figure 3.3 describes and shows the layout of the SIB byte[1].


  
Figure: SIB byte. The SIB byte consists of a 2 bit scale field, a 3 bit index field, and 3 bit base field. It specifies the based indexed and scaled indexed forms of 32-bit addressing.
\begin{figure*}
\centerline{\protect
\mbox{\psfig{figure=Figs/sibformat.eps,height=0.12\textheight}}}
\rule{6.5in}{0.3mm}\\
\end{figure*}

In addition to the 32 addressing modes added by SIB byte, the ModR/M byte can now be used to specify 32 new 32-bit addressing forms along with its original 32 16-bit addressing forms. Thus, there are a total of 96 address forms that can be used in Sim386. We incorporated the additional 64 addressing forms into the existing design. In particular, we modified the MemOp class to decode both the 16-bit and 32-bit addressing forms given by the ModR/M byte and added the decode and interpretation of the SIB byte to get the based indexed and scaled indexed forms of addressing. Figure 3.4 shows the algorithm used to compute the address specified by the SIB byte.


  
Figure: Decoding SIB byte: This pseudo-code demonstrates a general method for calculating the correct address according to the field values of the SIB byte.
\begin{figure}
\begin{tex2html_preform}\begin{verbatim}unsigned char BASE = SIB ...
...ster[ebp];
}\end{verbatim}\end{tex2html_preform}\rule{6.5in}{0.3mm}
\end{figure}


next up previous contents
Next: Modifying and extending the Up: Adding 32-bit processing Previous: Adding 32-bit processing
Michael L. Haungs
1998-09-21