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

   
Modifying the registers, segments, and descriptors

An important difference in the 80386 as compared to the 80286 is the increase in register size from 16 bits to 32 bits, the addition of two more segment registers, and 3 more control registers. In extending Sim286 to Sim386, we increased the sizes of the general and segment registers, added the two additional segment registers, but did not add the new control registers. The three new control registers are mainly used by paging mechanisms, a feature not implemented in Sim386. In Section 3.1 of this paper, we note that different initialization code for the simulator was needed to simulate different platforms. Much of the difference in this initialization code stems from the different initial settings for the stack pointer, instruction pointer, control register, and segment registers and segment descriptors. For example, Sim286 sets the IP register to 0x100, sets SP to 0xFFFE, sets the D-bit in the code segment to 0, and maps all segments to an area of memory whose addresses range from 0x100 to 0xFFFF. These settings are all appropriate for a COM file assumed to be running on MS-DOS, a flat segmentation model. In order to simulate an ELF binary object file that was compiled on a machine running Linux, a protected flat model, the EIP must be set to agree with the information it extracts from the ELF object file. Also, the ESP must be set so that the stack does not interfere with any program data, the D-bit must be set in the code segment to 1, and all segments must be mapped to the area of memory whose addresses range between 0x00000000 and 0xC0000000. Both MS-DOS and Solaris use a flat model of segmentation while Linux uses a protected flat model of segmentation.


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