Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2778

Show
Ignore:
Timestamp:
11/05/07 14:51:31 (1 year ago)
Author:
sean
Message:

Merged in changes from DMD 1.023.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/compiler/dmd/minit.asm

    r454 r2778  
    11;_ minit.asm 
    2 ; Copyright (C) 2001 by Digital Mars 
    3 ; All rights reserved 
    4 ; www.digitalmars.com 
    5  
    6 ; Converts array of ModuleInfo pointers to a D dynamic array of them, 
    7 ; so they can be accessed via D. 
     2; Written by Walter Bright 
     3; Digital Mars 
     4; http://www.digitalmars.com/d/ 
     5; Placed into the Public Domain 
    86 
    97include macros.asm 
     
    1513endif 
    1614 
     15; Provide a default resolution for weak extern records, no way in C 
     16; to define an omf symbol with a specific value 
    1717public __nullext 
    18 __nullext  equ 0 
     18__nullext   equ 0 
    1919 
    20     extrn   __moduleinfo_array:near 
     20    extrn   __moduleinfo_array:near 
     21 
     22; This bit of assembler is needed because, from C or D, one cannot 
     23; specify the names of data segments. Why does this matter? 
     24; All the ModuleInfo pointers are placed into a segment named 'FM'. 
     25; The order in which they are placed in 'FM' is arbitrarily up to the linker. 
     26; In order to walk all the pointers, we need to be able to find the 
     27; beginning and the end of the 'FM' segment. 
     28; This is done by bracketing the 'FM' segment with two other, empty, 
     29; segments named 'FMB' and 'FME'. Since this module is the only one that 
     30; ever refers to 'FMB' and 'FME', we get to control the order in which 
     31; these segments appear relative to 'FM' by using a GROUP statement. 
     32; So, we have in memory: 
     33;   FMB empty segment 
     34;   FM  contains all the pointers 
     35;   FME empty segment 
     36; and finding the limits of FM is as easy as taking the address of FMB 
     37; and the address of FME. 
    2138 
    2239; These segments bracket FM, which contains the list of ModuleInfo pointers 
     
    3249XOB     ends 
    3350XO      segment dword use32 public 'BSS' 
    34    dd 
     51    dd 
    3552XO      ends 
    3653XOE     segment dword use32 public 'BSS' 
     
    3956DGROUP         group   FMB,FM,FME 
    4057 
    41    begcode minit 
     58    begcode minit 
    4259 
    43     public  __minit 
    44 __minit proc    near 
    45     mov EDX,offset DATAGRP:FMB 
    46     mov EAX,offset DATAGRP:FME 
    47     mov dword ptr __moduleinfo_array+4,EDX 
    48     sub EAX,EDX         ; size in bytes of FM segment 
    49     shr EAX,2           ; convert to array length 
    50     mov dword ptr __moduleinfo_array,EAX 
    51     ret 
     60; extern (C) void _minit(); 
     61; Converts array of ModuleInfo pointers to a D dynamic array of them, 
     62; so they can be accessed via D. 
     63; Result is written to: 
     64; extern (C) ModuleInfo[] _moduleinfo_array; 
     65 
     66    public  __minit 
     67__minit proc    near 
     68    mov EDX,offset DATAGRP:FMB 
     69    mov EAX,offset DATAGRP:FME 
     70    mov dword ptr __moduleinfo_array+4,EDX 
     71    sub EAX,EDX         ; size in bytes of FM segment 
     72    shr EAX,2           ; convert to array length 
     73    mov dword ptr __moduleinfo_array,EAX 
     74    ret 
    5275__minit endp 
    5376 
    54    endcode minit 
     77    endcode minit 
    5578 
    56    end 
     79    end