Protected Mode
Protected Mode (1 of 2) 4 GB addressable RAM –( to FFFFFFFFh) Each program assigned a memory partition which is protected from other programs Designed for multitasking Supported by Linux & MS-Windows
Protected Mode memory segmentation is defined by a set of tables (descriptor tables) and the segment registers contain pointers into these tables. Each table entry is 8- bytes wide. Global Descriptor Table (GDT), all applications can access Local Descriptor Table (LDT), specific to a task or program. Segment registers don't form part of the physical address in protected mode, but instead are used as pointers to table entries in the GDT or LDT
Protected mode (2 of 2) Segment descriptor tables Program structure –code, data, and stack areas –CS, DS, SS segment descriptors –global descriptor table (GDT) MASM Programs use the Microsoft flat memory model
Memory Management n Protected Mode (flat model) Allows the microprocessor to address up to 4G byte of memory space Selector, located in segment register, selects one of 8192 descriptors from one of two tables of descriptors
Memory Management n Protected Mode (flat model) Descriptor, describes the location, length, and access rights of the segment of memory Global descriptor table (GDT) Local descriptor table (LDT)
Memory Management n Protected Mode (flat model) Base address – indicates the starting location of the memory segment 24-bit for the – segments begin at any location in its 16M bytes of memory 32-bit for the and above - segments begin at any location in its 4G bytes of memory Segment limit – contains the last offset address found in segment Granularity bit (for and above)---- G=0, the limit specifies a segment limit of 00000H to FFFFFH; G=1, the value of limit is multiplied by 4K bytes (00000XXXH to FFFFFXXXH)
Memory Management n Protected Mode (flat model) D bit – indicate how the instructions access register and memory data in protected mode D=0, instructions are 16-bit instructions, with 16-bit offsets and 16-bit registers. Compatible with 8086 ~ D=1, 32-bit is assumed AV bit – used by operating systems AV=1, segment is available AV=0, segment is not available
Memory Management n Protected Mode (flat model) The Access Right
Which memory locations will be used as the data segment?
Flat Segment Model Single global descriptor table (GDT). All segments mapped to entire 32-bit address space
Multi-Segment Model Each program has a local descriptor table (LDT) –holds descriptor for each segment used by the program
Paging Supported directly by the CPU Divides each segment into 4096-byte blocks called pages Sum of all programs can be larger than physical memory Part of running program is in memory, part is on disk Virtual memory manager (VMM) – OS utility that manages the loading and unloading of pages Page fault – issued by CPU when a page must be loaded from disk
Assembling, Linking and Running Source file (.asm) Text editor Assembler Object file (.obj) Listing file (.lst) Linker Link library (.lib) Executable program (.exe) Map file (.map) Dos Loader Output ML
n Assembling Assembling, Linking and Running Two staged process: Assemble: Converts assembly language into machine language. Uses source file, outputs object file and optionally the list file Link: Connects (links) the different.obj and library files together to create the executable file. Uses the object file(s) and optionally a library. Outputs executable file and optionally map file Both done with ML command
MASM Installation Insert CD in CD-Rom Go to Desktop, select My Computer Select CD-ROM directory Double click “index.html” On the new screen, follow the links, install MASM615 Install TextPad Editor and follow the link to install appropriate Tool Menu Command for 32-bit MASM Program (See the following link for details: dex.html#AddToolshttp:// dex.html#AddTools)
MASM Installation “Run MASM Prog” Command n Corrections for the installation of Tool Commands in TextPad Should be $BaseName.exe